/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//* vim: set ts=8 sts=2 et sw=2 tw=80: *//* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. *//* * structs that contain the data provided by nsStyleContext, the * internal API for computed style data for an element */#ifndef nsStyleStruct_h___#define nsStyleStruct_h___#include"mozilla/ArenaObjectID.h"#include"mozilla/Attributes.h"#include"mozilla/CSSVariableValues.h"#include"mozilla/Maybe.h"#include"mozilla/SheetType.h"#include"mozilla/StaticPtr.h"#include"mozilla/StyleComplexColor.h"#include"mozilla/UniquePtr.h"#include"nsColor.h"#include"nsCoord.h"#include"nsMargin.h"#include"nsFont.h"#include"nsStyleAutoArray.h"#include"nsStyleCoord.h"#include"nsStyleConsts.h"#include"nsChangeHint.h"#include"nsPresContext.h"#include"nsCOMPtr.h"#include"nsCOMArray.h"#include"nsTArray.h"#include"nsCSSValue.h"#include"imgRequestProxy.h"#include"Orientation.h"#include"CounterStyleManager.h"#include<cstddef> // offsetof()#include<utility>#include"X11UndefineNone.h"classnsIFrame;classnsIURI;classnsStyleContext;classnsTextFrame;classimgIContainer;structnsStyleVisibility;namespacemozilla{namespacedom{classImageTracker;}// namespace dom}// namespace mozilla// Includes nsStyleStructID.#include"nsStyleStructFwd.h"// Bits for each struct.// NS_STYLE_INHERIT_BIT defined in nsStyleStructFwd.h#define NS_STYLE_INHERIT_MASK 0x000ffffff// Bits for inherited structs.#define NS_STYLE_INHERITED_STRUCT_MASK \ ((nsStyleStructID_size_t(1) << nsStyleStructID_Inherited_Count) - 1)// Bits for reset structs.#define NS_STYLE_RESET_STRUCT_MASK \ (((nsStyleStructID_size_t(1) << nsStyleStructID_Reset_Count) - 1) \ << nsStyleStructID_Inherited_Count)// Additional bits for nsStyleContext's mBits:// See nsStyleContext::HasTextDecorationLines#define NS_STYLE_HAS_TEXT_DECORATION_LINES 0x001000000// See nsStyleContext::HasPseudoElementData.#define NS_STYLE_HAS_PSEUDO_ELEMENT_DATA 0x002000000// See nsStyleContext::RelevantLinkIsVisited#define NS_STYLE_RELEVANT_LINK_VISITED 0x004000000// See nsStyleContext::IsStyleIfVisited#define NS_STYLE_IS_STYLE_IF_VISITED 0x008000000// See nsStyleContext::HasChildThatUsesGrandancestorStyle#define NS_STYLE_CHILD_USES_GRANDANCESTOR_STYLE 0x010000000// See nsStyleContext::IsShared#define NS_STYLE_IS_SHARED 0x020000000// See nsStyleContext::AssertStructsNotUsedElsewhere// (This bit is currently only used in #ifdef DEBUG code.)#define NS_STYLE_IS_GOING_AWAY 0x040000000// See nsStyleContext::ShouldSuppressLineBreak#define NS_STYLE_SUPPRESS_LINEBREAK 0x080000000// See nsStyleContext::IsInDisplayNoneSubtree#define NS_STYLE_IN_DISPLAY_NONE_SUBTREE 0x100000000// See nsStyleContext::FindChildWithRules#define NS_STYLE_INELIGIBLE_FOR_SHARING 0x200000000// See nsStyleContext::HasChildThatUsesResetStyle#define NS_STYLE_HAS_CHILD_THAT_USES_RESET_STYLE 0x400000000// See nsStyleContext::IsTextCombined#define NS_STYLE_IS_TEXT_COMBINED 0x800000000// Whether a style context is a Gecko or Servo context#define NS_STYLE_CONTEXT_IS_GECKO 0x1000000000// See nsStyleContext::GetPseudoEnum#define NS_STYLE_CONTEXT_TYPE_SHIFT 37// Additional bits for nsRuleNode's mDependentBits:#define NS_RULE_NODE_IS_ANIMATION_RULE 0x01000000// Free bit 0x02000000#define NS_RULE_NODE_USED_DIRECTLY 0x04000000#define NS_RULE_NODE_IS_IMPORTANT 0x08000000#define NS_RULE_NODE_LEVEL_MASK 0xf0000000#define NS_RULE_NODE_LEVEL_SHIFT 28// Additional bits for nsRuleNode's mNoneBits:#define NS_RULE_NODE_HAS_ANIMATION_DATA 0x80000000static_assert(int(mozilla::SheetType::Count)-1<=(NS_RULE_NODE_LEVEL_MASK>>NS_RULE_NODE_LEVEL_SHIFT),"NS_RULE_NODE_LEVEL_MASK cannot fit SheetType");static_assert(NS_STYLE_INHERIT_MASK==(1<<nsStyleStructID_Length)-1,"NS_STYLE_INHERIT_MASK is not correct");static_assert((NS_RULE_NODE_IS_ANIMATION_RULE&NS_STYLE_INHERIT_MASK)==0,"NS_RULE_NODE_IS_ANIMATION_RULE must not overlap the style struct bits.");namespacemozilla{structPosition{usingCoord=nsStyleCoord::CalcValue;CoordmXPosition,mYPosition;// Initialize nothingPosition(){}// Sets both mXPosition and mYPosition to the given percent value for the// initial property-value (e.g. 0.0f for "0% 0%", or 0.5f for "50% 50%")voidSetInitialPercentValues(floataPercentVal);// Sets both mXPosition and mYPosition to 0 (app units) for the// initial property-value as a length with no percentage component.voidSetInitialZeroValues();// True if the effective background image position described by this depends// on the size of the corresponding frame.boolDependsOnPositioningAreaSize()const{returnmXPosition.mPercent!=0.0f||mYPosition.mPercent!=0.0f;}booloperator==(constPosition&aOther)const{returnmXPosition==aOther.mXPosition&&mYPosition==aOther.mYPosition;}booloperator!=(constPosition&aOther)const{return!(*this==aOther);}};}// namespace mozilla// The lifetime of these objects is managed by the presshell's arena.structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleFont{nsStyleFont(constnsFont&aFont,constnsPresContext*aContext);nsStyleFont(constnsStyleFont&aStyleFont);explicitnsStyleFont(constnsPresContext*aContext);~nsStyleFont(){MOZ_COUNT_DTOR(nsStyleFont);}voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;nsChangeHintCalcDifference(constnsStyleFont&aNewData)const;/** * Return aSize multiplied by the current text zoom factor (in aPresContext). * aSize is allowed to be negative, but the caller is expected to deal with * negative results. The result is clamped to nscoord_MIN .. nscoord_MAX. */staticnscoordZoomText(constnsPresContext*aPresContext,nscoordaSize);/** * Return aSize divided by the current text zoom factor (in aPresContext). * aSize is allowed to be negative, but the caller is expected to deal with * negative results. The result is clamped to nscoord_MIN .. nscoord_MAX. */staticnscoordUnZoomText(nsPresContext*aPresContext,nscoordaSize);staticalready_AddRefed<nsIAtom>GetLanguage(constnsPresContext*aPresContext);void*operatornew(size_tsz,nsStyleFont*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleFont,sz);}voidDestroy(nsPresContext*aContext);voidEnableZoom(nsPresContext*aContext,boolaEnable);nsFontmFont;// [inherited]nscoordmSize;// [inherited] Our "computed size". Can be different// from mFont.size which is our "actual size" and is// enforced to be >= the user's preferred min-size.// mFont.size should be used for display purposes// while mSize is the value to return in// getComputedStyle() for example.uint8_tmGenericID;// [inherited] generic CSS font family, if any;// value is a kGenericFont_* constant, see nsFont.h.// MathML scriptlevel supportint8_tmScriptLevel;// [inherited]// MathML mathvariant supportuint8_tmMathVariant;// [inherited]// MathML displaystyle supportuint8_tmMathDisplay;// [inherited]// allow different min font-size for certain casesuint8_tmMinFontSizeRatio;// [inherited] percent * 100// was mLanguage set based on a lang attribute in the document?boolmExplicitLanguage;// [inherited]// should calls to ZoomText() and UnZoomText() be made to the font// size on this nsStyleFont?boolmAllowZoom;// [inherited]// The value mSize would have had if scriptminsize had never been appliednscoordmScriptUnconstrainedSize;nscoordmScriptMinSize;// [inherited] lengthfloatmScriptSizeMultiplier;// [inherited]nsCOMPtr<nsIAtom>mLanguage;// [inherited]};structnsStyleGradientStop{nsStyleCoordmLocation;// percent, coord, calc, nonenscolormColor;boolmIsInterpolationHint;// Use ==/!= on nsStyleGradient instead of on the gradient stop.booloperator==(constnsStyleGradientStop&)const=delete;booloperator!=(constnsStyleGradientStop&)const=delete;};classnsStyleGradientfinal{public:nsStyleGradient();uint8_tmShape;// NS_STYLE_GRADIENT_SHAPE_*uint8_tmSize;// NS_STYLE_GRADIENT_SIZE_*;// not used (must be FARTHEST_CORNER) for linear shapeboolmRepeating;boolmLegacySyntax;// If true, serialization should use a vendor prefix.// XXXdholbert This will hopefully be going away soon, if bug 1337655 sticks:boolmMozLegacySyntax;// (Only makes sense when mLegacySyntax is true.)// If true, serialization should use -moz prefix.// Else, serialization should use -webkit prefix.nsStyleCoordmBgPosX;// percent, coord, calc, nonensStyleCoordmBgPosY;// percent, coord, calc, nonensStyleCoordmAngle;// none, anglensStyleCoordmRadiusX;// percent, coord, calc, nonensStyleCoordmRadiusY;// percent, coord, calc, none// stops are in the order specified in the stylesheetnsTArray<nsStyleGradientStop>mStops;booloperator==(constnsStyleGradient&aOther)const;booloperator!=(constnsStyleGradient&aOther)const{return!(*this==aOther);}boolIsOpaque();boolHasCalc();uint32_tHash(PLDHashNumberaHash);NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsStyleGradient)private:// Private destructor, to discourage deletion outside of Release():~nsStyleGradient(){}nsStyleGradient(constnsStyleGradient&aOther)=delete;nsStyleGradient&operator=(constnsStyleGradient&aOther)=delete;};/** * A wrapper for an imgRequestProxy that supports off-main-thread creation * and equality comparison. * * An nsStyleImageRequest can be created in two ways: * * 1. Using the constructor that takes an imgRequestProxy. This must * be called from the main thread. The nsStyleImageRequest is * immediately considered "resolved", and the get() method that * returns the imgRequestProxy can be called. * * 2. Using the constructor that takes the URL, base URI, referrer * and principal that can be used to inititiate an image load and * produce an imgRequestProxy later. This can be called from * any thread. The nsStyleImageRequest is not considered "resolved" * at this point, and the Resolve() method must be called later * to initiate the image load and make calls to get() valid. * * Calls to TrackImage(), UntrackImage(), LockImage(), UnlockImage() and * RequestDiscard() are made to the imgRequestProxy and ImageTracker as * appropriate, according to the mode flags passed in to the constructor. * * The main thread constructor takes a pointer to the css::ImageValue that * is the specified url() value, while the off-main-thread constructor * creates a new css::ImageValue to represent the url() information passed * to the constructor. This ImageValue is held on to for the comparisons done * in DefinitelyEquals(), so that we don't need to call into the non-OMT-safe * Equals() on the nsIURI objects returned from imgRequestProxy::GetURI(). */classnsStyleImageRequest{public:typedefmozilla::css::URLValueDataURLValueData;// Flags describing whether the imgRequestProxy must be tracked in the// ImageTracker, whether LockImage/UnlockImage calls will be made// when obtaining and releasing the imgRequestProxy, and whether// RequestDiscard will be called on release.enumclassMode:uint8_t{// The imgRequestProxy will be added to the ImageTracker when resolved// Without this flag, the nsStyleImageRequest itself will call LockImage/// UnlockImage on the imgRequestProxy, rather than leaving locking to the// ImageTracker to manage.//// This flag is currently used by all nsStyleImageRequests except// those for list-style-image and cursor.Track=0x1,// The imgRequestProxy will have its RequestDiscard method called when// the nsStyleImageRequest is going away.//// This is currently used only for cursor images.Discard=0x2,};// Must be called from the main thread.//// aImageTracker must be non-null iff aModeFlags contains Track.nsStyleImageRequest(ModeaModeFlags,imgRequestProxy*aRequestProxy,mozilla::css::ImageValue*aImageValue,mozilla::dom::ImageTracker*aImageTracker);// Can be called from any thread, but Resolve() must be called later// on the main thread before get() can be used.nsStyleImageRequest(ModeaModeFlags,mozilla::css::ImageValue*aImageValue);boolResolve(nsPresContext*aPresContext);boolIsResolved()const{returnmResolved;}imgRequestProxy*get(){MOZ_ASSERT(IsResolved(),"Resolve() must be called first");MOZ_ASSERT(NS_IsMainThread());returnmRequestProxy.get();}constimgRequestProxy*get()const{returnconst_cast<nsStyleImageRequest*>(this)->get();}// Returns whether the ImageValue objects in the two nsStyleImageRequests// return true from URLValueData::DefinitelyEqualURIs.boolDefinitelyEquals(constnsStyleImageRequest&aOther)const;mozilla::css::ImageValue*GetImageValue()const{returnmImageValue;}already_AddRefed<nsIURI>GetImageURI()const;NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsStyleImageRequest);private:~nsStyleImageRequest();nsStyleImageRequest&operator=(constnsStyleImageRequest&aOther)=delete;voidMaybeTrackAndLock();RefPtr<imgRequestProxy>mRequestProxy;RefPtr<mozilla::css::ImageValue>mImageValue;RefPtr<mozilla::dom::ImageTracker>mImageTracker;// Cache DocGroup for dispatching events in the destructor.RefPtr<mozilla::dom::DocGroup>mDocGroup;ModemModeFlags;boolmResolved;};MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsStyleImageRequest::Mode)enumnsStyleImageType{eStyleImageType_Null,eStyleImageType_Image,eStyleImageType_Gradient,eStyleImageType_Element,eStyleImageType_URL};structCachedBorderImageData{// Caller are expected to ensure that the value of aSVGViewportSize is// different from the cached one since the method won't do the check.voidSetCachedSVGViewportSize(constmozilla::Maybe<nsSize>&aSVGViewportSize);constmozilla::Maybe<nsSize>&GetCachedSVGViewportSize();voidPurgeCachedImages();voidSetSubImage(uint8_taIndex,imgIContainer*aSubImage);imgIContainer*GetSubImage(uint8_taIndex);private:// If this is a SVG border-image, we save the size of the SVG viewport that// we used when rasterizing any cached border-image subimages. (The viewport// size matters for percent-valued sizes & positions in inner SVG doc).mozilla::Maybe<nsSize>mCachedSVGViewportSize;nsCOMArray<imgIContainer>mSubImages;};/** * Represents a paintable image of one of the following types. * (1) A real image loaded from an external source. * (2) A CSS linear or radial gradient. * (3) An element within a document, or an <img>, <video>, or <canvas> element * not in a document. * (*) Optionally a crop rect can be set to paint a partial (rectangular) * region of an image. (Currently, this feature is only supported with an * image of type (1)). */structnsStyleImage{typedefmozilla::css::URLValueURLValue;typedefmozilla::css::URLValueDataURLValueData;nsStyleImage();~nsStyleImage();nsStyleImage(constnsStyleImage&aOther);nsStyleImage&operator=(constnsStyleImage&aOther);voidSetNull();voidSetImageRequest(already_AddRefed<nsStyleImageRequest>aImage);voidSetGradientData(nsStyleGradient*aGradient);voidSetElementId(already_AddRefed<nsIAtom>aElementId);voidSetCropRect(mozilla::UniquePtr<nsStyleSides>aCropRect);voidSetURLValue(already_AddRefed<URLValue>aData);voidResolveImage(nsPresContext*aContext){MOZ_ASSERT(mType!=eStyleImageType_Image||mImage);if(mType==eStyleImageType_Image&&!mImage->IsResolved()){mImage->Resolve(aContext);}}nsStyleImageTypeGetType()const{returnmType;}nsStyleImageRequest*GetImageRequest()const{MOZ_ASSERT(mType==eStyleImageType_Image,"Data is not an image!");MOZ_ASSERT(mImage);returnmImage;}imgRequestProxy*GetImageData()const{returnGetImageRequest()->get();}nsStyleGradient*GetGradientData()const{NS_ASSERTION(mType==eStyleImageType_Gradient,"Data is not a gradient!");returnmGradient;}constnsIAtom*GetElementId()const{NS_ASSERTION(mType==eStyleImageType_Element,"Data is not an element!");returnmElementId;}constmozilla::UniquePtr<nsStyleSides>&GetCropRect()const{NS_ASSERTION(mType==eStyleImageType_Image,"Only image data can have a crop rect");returnmCropRect;}already_AddRefed<nsIURI>GetImageURI()const;URLValueData*GetURLValue()const;/** * Compute the actual crop rect in pixels, using the source image bounds. * The computation involves converting percentage unit to pixel unit and * clamping each side value to fit in the source image bounds. * @param aActualCropRect the computed actual crop rect. * @param aIsEntireImage true iff |aActualCropRect| is identical to the * source image bounds. * @return true iff |aActualCropRect| holds a meaningful value. */boolComputeActualCropRect(nsIntRect&aActualCropRect,bool*aIsEntireImage=nullptr)const;/** * Starts the decoding of a image. Returns true if the current frame of the * image is complete. The return value is intended to be used instead of * IsComplete because IsComplete may not be up to date if notifications * from decoding are pending because they are being sent async. */boolStartDecoding()const;/** * @return true if the item is definitely opaque --- i.e., paints every * pixel within its bounds opaquely, and the bounds contains at least a pixel. */boolIsOpaque()const;/** * @return true if this image is fully loaded, and its size is calculated; * always returns true if |mType| is |eStyleImageType_Gradient| or * |eStyleImageType_Element|. */boolIsComplete()const;/** * @return true if this image is loaded without error; * always returns true if |mType| is |eStyleImageType_Gradient| or * |eStyleImageType_Element|. */boolIsLoaded()const;/** * @return true if it is 100% confident that this image contains no pixel * to draw. */boolIsEmpty()const{// There are some other cases when the image will be empty, for example// when the crop rect is empty. However, checking the emptiness of crop// rect is non-trivial since each side value can be specified with// percentage unit, which can not be evaluated until the source image size// is available. Therefore, we currently postpone the evaluation of crop// rect until the actual rendering time --- alternatively until GetOpaqueRegion()// is called.returnmType==eStyleImageType_Null;}booloperator==(constnsStyleImage&aOther)const;booloperator!=(constnsStyleImage&aOther)const{return!(*this==aOther);}boolImageDataEquals(constnsStyleImage&aOther)const{returnGetType()==eStyleImageType_Image&&aOther.GetType()==eStyleImageType_Image&&GetImageData()==aOther.GetImageData();}// These methods are used for the caller to caches the sub images created// during a border-image paint operationinlinevoidSetSubImage(uint8_taIndex,imgIContainer*aSubImage)const;inlineimgIContainer*GetSubImage(uint8_taIndex)const;voidPurgeCacheForViewportChange(constmozilla::Maybe<nsSize>&aSVGViewportSize,constboolaHasIntrinsicRatio)const;private:voidDoCopy(constnsStyleImage&aOther);voidEnsureCachedBIData()const;// This variable keeps some cache data for border image and is lazily// allocated since it is only used in border image case.mozilla::UniquePtr<CachedBorderImageData>mCachedBIData;nsStyleImageTypemType;union{nsStyleImageRequest*mImage;nsStyleGradient*mGradient;URLValue*mURLValue;// See the comment in SetStyleImage's 'case// eCSSUnit_URL' section to know why we need to// store URLValues separately from mImage.nsIAtom*mElementId;};// This is _currently_ used only in conjunction with eStyleImageType_Image.mozilla::UniquePtr<nsStyleSides>mCropRect;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleColor{explicitnsStyleColor(constnsPresContext*aContext);nsStyleColor(constnsStyleColor&aOther);~nsStyleColor(){MOZ_COUNT_DTOR(nsStyleColor);}voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;nscolorCalcComplexColor(constmozilla::StyleComplexColor&aColor)const{returnmozilla::LinearBlendColors(aColor.mColor,mColor,aColor.mForegroundRatio);}nsChangeHintCalcDifference(constnsStyleColor&aNewData)const;void*operatornew(size_tsz,nsStyleColor*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleColor,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleColor();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleColor,this);}// Don't add ANY members to this struct! We can achieve caching in the rule// tree (rather than the style tree) by letting color stay by itself! -dwhnscolormColor;// [inherited]};structnsStyleImageLayers{// Indices into kBackgroundLayerTable and kMaskLayerTableenum{shorthand=0,color,image,repeat,positionX,positionY,clip,origin,size,attachment,maskMode,composite};enumclassLayerType:uint8_t{Background=0,Mask};explicitnsStyleImageLayers(LayerTypeaType);nsStyleImageLayers(constnsStyleImageLayers&aSource);~nsStyleImageLayers(){MOZ_COUNT_DTOR(nsStyleImageLayers);}staticboolIsInitialPositionForLayerType(mozilla::PositionaPosition,LayerTypeaType);structSize;friendstructSize;structSize{structDimension:publicnsStyleCoord::CalcValue{nscoordResolveLengthPercentage(nscoordaAvailable)const{doubled=double(mPercent)*double(aAvailable)+double(mLength);if(d<0.0){return0;}returnNSToCoordRoundWithClamp(float(d));}};DimensionmWidth,mHeight;boolIsInitialValue()const{returnmWidthType==eAuto&&mHeightType==eAuto;}nscoordResolveWidthLengthPercentage(constnsSize&aBgPositioningArea)const{MOZ_ASSERT(mWidthType==eLengthPercentage,"resolving non-length/percent dimension!");returnmWidth.ResolveLengthPercentage(aBgPositioningArea.width);}nscoordResolveHeightLengthPercentage(constnsSize&aBgPositioningArea)const{MOZ_ASSERT(mHeightType==eLengthPercentage,"resolving non-length/percent dimension!");returnmHeight.ResolveLengthPercentage(aBgPositioningArea.height);}// Except for eLengthPercentage, Dimension types which might change// how a layer is painted when the corresponding frame's dimensions// change *must* precede all dimension types which are agnostic to// frame size; see DependsOnDependsOnPositioningAreaSizeSize.enumDimensionType{// If one of mWidth and mHeight is eContain or eCover, then both are.// NOTE: eContain and eCover *must* be equal to NS_STYLE_BG_SIZE_CONTAIN// and NS_STYLE_BG_SIZE_COVER (in kBackgroundSizeKTable).eContain,eCover,eAuto,eLengthPercentage,eDimensionType_COUNT};uint8_tmWidthType,mHeightType;// True if the effective image size described by this depends on the size of// the corresponding frame, when aImage (which must not have null type) is// the background image.boolDependsOnPositioningAreaSize(constnsStyleImage&aImage)const;// Initialize nothingSize(){}// Initialize to initial valuesvoidSetInitialValues();booloperator==(constSize&aOther)const;booloperator!=(constSize&aOther)const{return!(*this==aOther);}};structRepeat;friendstructRepeat;structRepeat{mozilla::StyleImageLayerRepeatmXRepeat,mYRepeat;// Initialize nothingRepeat(){}boolIsInitialValue()const{returnmXRepeat==mozilla::StyleImageLayerRepeat::Repeat&&mYRepeat==mozilla::StyleImageLayerRepeat::Repeat;}boolDependsOnPositioningAreaSize()const{returnmXRepeat==mozilla::StyleImageLayerRepeat::Space||mYRepeat==mozilla::StyleImageLayerRepeat::Space;}// Initialize to initial valuesvoidSetInitialValues(){mXRepeat=mozilla::StyleImageLayerRepeat::Repeat;mYRepeat=mozilla::StyleImageLayerRepeat::Repeat;}booloperator==(constRepeat&aOther)const{returnmXRepeat==aOther.mXRepeat&&mYRepeat==aOther.mYRepeat;}booloperator!=(constRepeat&aOther)const{return!(*this==aOther);}};structLayer;friendstructLayer;structLayer{typedefmozilla::StyleGeometryBoxStyleGeometryBox;nsStyleImagemImage;// [reset]mozilla::PositionmPosition;// [reset]SizemSize;// [reset]StyleGeometryBoxmClip;// [reset] See nsStyleConsts.hMOZ_INIT_OUTSIDE_CTORStyleGeometryBoxmOrigin;// [reset] See nsStyleConsts.huint8_tmAttachment;// [reset] See nsStyleConsts.h// background-only property// This property is used for background layer// only. For a mask layer, it should always// be the initial value, which is// NS_STYLE_IMAGELAYER_ATTACHMENT_SCROLL.uint8_tmBlendMode;// [reset] See nsStyleConsts.h// background-only property// This property is used for background layer// only. For a mask layer, it should always// be the initial value, which is// NS_STYLE_BLEND_NORMAL.uint8_tmComposite;// [reset] See nsStyleConsts.h// mask-only property// This property is used for mask layer only.// For a background layer, it should always// be the initial value, which is// NS_STYLE_COMPOSITE_MODE_ADD.uint8_tmMaskMode;// [reset] See nsStyleConsts.h// mask-only property// This property is used for mask layer only.// For a background layer, it should always// be the initial value, which is// NS_STYLE_MASK_MODE_MATCH_SOURCE.RepeatmRepeat;// [reset] See nsStyleConsts.h// This constructor does not initialize mRepeat or mOrigin and Initialize()// must be called to do that.Layer();~Layer();// Initialize mRepeat and mOrigin by specified layer typevoidInitialize(LayerTypeaType);voidResolveImage(nsPresContext*aContext){if(mImage.GetType()==eStyleImageType_Image){mImage.ResolveImage(aContext);}}// True if the rendering of this layer might change when the size// of the background positioning area changes. This is true for any// non-solid-color background whose position or size depends on// the size of the positioning area. It's also true for SVG images// whose root <svg> node has a viewBox.boolRenderingMightDependOnPositioningAreaSizeChange()const;// Compute the change hint required by changes in just this layer.nsChangeHintCalcDifference(constLayer&aNewLayer)const;// An equality operator that compares the images using URL-equality// rather than pointer-equality.booloperator==(constLayer&aOther)const;booloperator!=(constLayer&aOther)const{return!(*this==aOther);}};// The (positive) number of computed values of each property, since// the lengths of the lists are independent.uint32_tmAttachmentCount,mClipCount,mOriginCount,mRepeatCount,mPositionXCount,mPositionYCount,mImageCount,mSizeCount,mMaskModeCount,mBlendModeCount,mCompositeCount;// Layers are stored in an array, matching the top-to-bottom order in// which they are specified in CSS. The number of layers to be used// should come from the background-image property. We create// additional |Layer| objects for *any* property, not just// background-image. This means that the bottommost layer that// callers in layout care about (which is also the one whose// background-clip applies to the background-color) may not be last// layer. In layers below the bottom layer, properties will be// uninitialized unless their count, above, indicates that they are// present.nsStyleAutoArray<Layer>mLayers;constLayer&BottomLayer()const{returnmLayers[mImageCount-1];}voidResolveImages(nsPresContext*aContext){for(uint32_ti=0;i<mImageCount;++i){mLayers[i].ResolveImage(aContext);}}nsChangeHintCalcDifference(constnsStyleImageLayers&aNewLayers,nsStyleImageLayers::LayerTypeaType)const;nsStyleImageLayers&operator=(constnsStyleImageLayers&aOther);nsStyleImageLayers&operator=(nsStyleImageLayers&&aOther);booloperator==(constnsStyleImageLayers&aOther)const;staticconstnsCSSPropertyIDkBackgroundLayerTable[];staticconstnsCSSPropertyIDkMaskLayerTable[];#define NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(var_, layers_) \ for (uint32_t var_ = (layers_).mImageCount; var_-- != 0; )#define NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT_WITH_RANGE(var_, layers_, start_, count_) \ NS_ASSERTION((int32_t)(start_) >= 0 && (uint32_t)(start_) < (layers_).mImageCount, "Invalid layer start!"); \ NS_ASSERTION((count_) > 0 && (count_) <= (start_) + 1, "Invalid layer range!"); \ for (uint32_t var_ = (start_) + 1; var_-- != (uint32_t)((start_) + 1 - (count_)); )};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleBackground{explicitnsStyleBackground(constnsPresContext*aContext);nsStyleBackground(constnsStyleBackground&aOther);~nsStyleBackground();// Resolves and tracks the images in mImage. Only called with a Servo-backed// style system, where those images must be resolved later than the OMT// nsStyleBackground constructor call.voidFinishStyle(nsPresContext*aPresContext);conststaticboolkHasFinishStyle=true;void*operatornew(size_tsz,nsStyleBackground*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleBackground,sz);}voidDestroy(nsPresContext*aContext);nsChangeHintCalcDifference(constnsStyleBackground&aNewData)const;// Return the background color as nscolor.nscolorBackgroundColor(constnsIFrame*aFrame)const;nscolorBackgroundColor(nsStyleContext*aContext)const;// True if this background is completely transparent.boolIsTransparent(constnsIFrame*aFrame)const;boolIsTransparent(nsStyleContext*aContext)const;// We have to take slower codepaths for fixed background attachment,// but we don't want to do that when there's no image.// Not inline because it uses an nsCOMPtr<imgIRequest>// FIXME: Should be in nsStyleStructInlines.h.boolHasFixedBackground(nsIFrame*aFrame)const;// Checks to see if this has a non-empty image with "local" attachment.// This is defined in nsStyleStructInlines.h.inlineboolHasLocalBackground()const;constnsStyleImageLayers::Layer&BottomLayer()const{returnmImage.BottomLayer();}nsStyleImageLayersmImage;mozilla::StyleComplexColormBackgroundColor;// [reset]};#define NS_SPACING_MARGIN 0#define NS_SPACING_PADDING 1#define NS_SPACING_BORDER 2structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleMargin{explicitnsStyleMargin(constnsPresContext*aContext);nsStyleMargin(constnsStyleMargin&aMargin);~nsStyleMargin(){MOZ_COUNT_DTOR(nsStyleMargin);}voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleMargin*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleMargin,sz);}voidDestroy(nsPresContext*aContext);nsChangeHintCalcDifference(constnsStyleMargin&aNewData)const;boolGetMargin(nsMargin&aMargin)const{if(!mMargin.ConvertsToLength()){returnfalse;}NS_FOR_CSS_SIDES(side){aMargin.Side(side)=mMargin.ToLength(side);}returntrue;}// Return true if either the start or end side in the axis is 'auto'.// (defined in WritingModes.h since we need the full WritingMode type)inlineboolHasBlockAxisAuto(mozilla::WritingModeaWM)const;inlineboolHasInlineAxisAuto(mozilla::WritingModeaWM)const;nsStyleSidesmMargin;// [reset] coord, percent, calc, auto};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStylePadding{explicitnsStylePadding(constnsPresContext*aContext);nsStylePadding(constnsStylePadding&aPadding);~nsStylePadding(){MOZ_COUNT_DTOR(nsStylePadding);}voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStylePadding*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStylePadding,sz);}voidDestroy(nsPresContext*aContext);nsChangeHintCalcDifference(constnsStylePadding&aNewData)const;nsStyleSidesmPadding;// [reset] coord, percent, calcboolIsWidthDependent()const{return!mPadding.ConvertsToLength();}boolGetPadding(nsMargin&aPadding)const{if(!mPadding.ConvertsToLength()){returnfalse;}NS_FOR_CSS_SIDES(side){// Clamp negative calc() to 0.aPadding.Side(side)=std::max(mPadding.ToLength(side),0);}returntrue;}};structnsBorderColors{nsBorderColors*mNext;nscolormColor;nsBorderColors():mNext(nullptr),mColor(NS_RGB(0,0,0)){}explicitnsBorderColors(constnscolor&aColor):mNext(nullptr),mColor(aColor){}~nsBorderColors();nsBorderColors*Clone()const{returnClone(true);}staticboolEqual(constnsBorderColors*c1,constnsBorderColors*c2){if(c1==c2){returntrue;}while(c1&&c2){if(c1->mColor!=c2->mColor){returnfalse;}c1=c1->mNext;c2=c2->mNext;}// both should be nullptr if these are equal, otherwise one// has more colors than anotherreturn!c1&&!c2;}private:nsBorderColors*Clone(boolaDeep)const;};structnsCSSShadowItem{nscoordmXOffset;nscoordmYOffset;nscoordmRadius;nscoordmSpread;nscolormColor;boolmHasColor;// Whether mColor should be usedboolmInset;nsCSSShadowItem():mHasColor(false){MOZ_COUNT_CTOR(nsCSSShadowItem);}~nsCSSShadowItem(){MOZ_COUNT_DTOR(nsCSSShadowItem);}booloperator==(constnsCSSShadowItem&aOther)const{return(mXOffset==aOther.mXOffset&&mYOffset==aOther.mYOffset&&mRadius==aOther.mRadius&&mHasColor==aOther.mHasColor&&mSpread==aOther.mSpread&&mInset==aOther.mInset&&(!mHasColor||mColor==aOther.mColor));}booloperator!=(constnsCSSShadowItem&aOther)const{return!(*this==aOther);}};classnsCSSShadowArrayfinal{public:void*operatornew(size_taBaseSize,uint32_taArrayLen){// We can allocate both this nsCSSShadowArray and the// actual array in one allocation. The amount of memory to// allocate is equal to the class's size + the number of bytes for all// but the first array item (because aBaseSize includes one// item, see the private declarations)return::operatornew(aBaseSize+(aArrayLen-1)*sizeof(nsCSSShadowItem));}explicitnsCSSShadowArray(uint32_taArrayLen):mLength(aArrayLen){for(uint32_ti=1;i<mLength;++i){// Make sure we call the constructors of each nsCSSShadowItem// (the first one is called for us because we declared it under private)new(&mArray[i])nsCSSShadowItem();}}private:// Private destructor, to discourage deletion outside of Release():~nsCSSShadowArray(){for(uint32_ti=1;i<mLength;++i){mArray[i].~nsCSSShadowItem();}}public:uint32_tLength()const{returnmLength;}nsCSSShadowItem*ShadowAt(uint32_ti){MOZ_ASSERT(i<mLength,"Accessing too high an index in the text shadow array!");return&mArray[i];}constnsCSSShadowItem*ShadowAt(uint32_ti)const{MOZ_ASSERT(i<mLength,"Accessing too high an index in the text shadow array!");return&mArray[i];}boolHasShadowWithInset(boolaInset){for(uint32_ti=0;i<mLength;++i){if(mArray[i].mInset==aInset){returntrue;}}returnfalse;}booloperator==(constnsCSSShadowArray&aOther)const{if(mLength!=aOther.Length()){returnfalse;}for(uint32_ti=0;i<mLength;++i){if(ShadowAt(i)!=aOther.ShadowAt(i)){returnfalse;}}returntrue;}NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsCSSShadowArray)private:uint32_tmLength;nsCSSShadowItemmArray[1];// This MUST be the last item};// Border widths are rounded to the nearest-below integer number of pixels,// but values between zero and one device pixels are always rounded up to// one device pixel.#define NS_ROUND_BORDER_TO_PIXELS(l,tpp) \ ((l) == 0) ? 0 : std::max((tpp), (l) / (tpp) * (tpp))// Outline offset is rounded to the nearest integer number of pixels, but values// between zero and one device pixels are always rounded up to one device pixel.// Note that the offset can be negative.#define NS_ROUND_OFFSET_TO_PIXELS(l,tpp) \ (((l) == 0) ? 0 : \ ((l) > 0) ? std::max( (tpp), ((l) + ((tpp) / 2)) / (tpp) * (tpp)) : \ std::min(-(tpp), ((l) - ((tpp) / 2)) / (tpp) * (tpp)))// Returns if the given border style type is visible or notstaticboolIsVisibleBorderStyle(uint8_taStyle){return(aStyle!=NS_STYLE_BORDER_STYLE_NONE&&aStyle!=NS_STYLE_BORDER_STYLE_HIDDEN);}structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleBorder{explicitnsStyleBorder(constnsPresContext*aContext);nsStyleBorder(constnsStyleBorder&aBorder);~nsStyleBorder();// Resolves and tracks mBorderImageSource. Only called with a Servo-backed// style system, where those images must be resolved later than the OMT// nsStyleBorder constructor call.voidFinishStyle(nsPresContext*aPresContext);conststaticboolkHasFinishStyle=true;void*operatornew(size_tsz,nsStyleBorder*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleBorder,sz);}voidDestroy(nsPresContext*aContext);nsChangeHintCalcDifference(constnsStyleBorder&aNewData)const;voidEnsureBorderColors(){if(!mBorderColors){mBorderColors=newnsBorderColors*[4];if(mBorderColors){for(int32_ti=0;i<4;i++){mBorderColors[i]=nullptr;}}}}voidClearBorderColors(mozilla::SideaSide){if(mBorderColors&&mBorderColors[aSide]){deletemBorderColors[aSide];mBorderColors[aSide]=nullptr;}}voidCopyBorderColorsFrom(constnsBorderColors*aSrcBorderColors,mozilla::SideaSide){if(aSrcBorderColors){EnsureBorderColors();ClearBorderColors(aSide);mBorderColors[aSide]=aSrcBorderColors->Clone();}}// Return whether aStyle is a visible style. Invisible styles cause// the relevant computed border width to be 0.// Note that this does *not* consider the effects of 'border-image':// if border-style is none, but there is a loaded border image,// HasVisibleStyle will be false even though there *is* a border.boolHasVisibleStyle(mozilla::SideaSide)const{returnIsVisibleBorderStyle(mBorderStyle[aSide]);}// aBorderWidth is in twipsvoidSetBorderWidth(mozilla::SideaSide,nscoordaBorderWidth){nscoordroundedWidth=NS_ROUND_BORDER_TO_PIXELS(aBorderWidth,mTwipsPerPixel);mBorder.Side(aSide)=roundedWidth;if(HasVisibleStyle(aSide)){mComputedBorder.Side(aSide)=roundedWidth;}}// Get the computed border (plus rounding). This does consider the// effects of 'border-style: none', but does not consider// 'border-image'.constnsMargin&GetComputedBorder()const{returnmComputedBorder;}boolHasBorder()const{returnmComputedBorder!=nsMargin(0,0,0,0)||!mBorderImageSource.IsEmpty();}// Get the actual border width for a particular side, in appunits. Note that// this is zero if and only if there is no border to be painted for this// side. That is, this value takes into account the border style and the// value is rounded to the nearest device pixel by NS_ROUND_BORDER_TO_PIXELS.nscoordGetComputedBorderWidth(mozilla::SideaSide)const{returnGetComputedBorder().Side(aSide);}uint8_tGetBorderStyle(mozilla::SideaSide)const{NS_ASSERTION(aSide<=mozilla::eSideLeft,"bad side");returnmBorderStyle[aSide];}voidSetBorderStyle(mozilla::SideaSide,uint8_taStyle){NS_ASSERTION(aSide<=mozilla::eSideLeft,"bad side");mBorderStyle[aSide]=aStyle;mComputedBorder.Side(aSide)=(HasVisibleStyle(aSide)?mBorder.Side(aSide):0);}inlineboolIsBorderImageLoaded()const{returnmBorderImageSource.IsLoaded();}voidResolveImage(nsPresContext*aContext){if(mBorderImageSource.GetType()==eStyleImageType_Image){mBorderImageSource.ResolveImage(aContext);}}nsMarginGetImageOutset()const;voidGetCompositeColors(int32_taIndex,nsBorderColors**aColors)const{if(!mBorderColors){*aColors=nullptr;}else{*aColors=mBorderColors[aIndex];}}voidAppendBorderColor(int32_taIndex,nscoloraColor){NS_ASSERTION(aIndex>=0&&aIndex<=3,"bad side for composite border color");nsBorderColors*colorEntry=newnsBorderColors(aColor);if(!mBorderColors[aIndex]){mBorderColors[aIndex]=colorEntry;}else{nsBorderColors*last=mBorderColors[aIndex];while(last->mNext){last=last->mNext;}last->mNext=colorEntry;}}imgIRequest*GetBorderImageRequest()const{if(mBorderImageSource.GetType()==eStyleImageType_Image){returnmBorderImageSource.GetImageData();}returnnullptr;}public:nsBorderColors**mBorderColors;// [reset] composite (stripe) colorsnsStyleCornersmBorderRadius;// [reset] coord, percentnsStyleImagemBorderImageSource;// [reset]nsStyleSidesmBorderImageSlice;// [reset] factor, percentnsStyleSidesmBorderImageWidth;// [reset] length, factor, percent, autonsStyleSidesmBorderImageOutset;// [reset] length, factoruint8_tmBorderImageFill;// [reset]uint8_tmBorderImageRepeatH;// [reset] see nsStyleConsts.huint8_tmBorderImageRepeatV;// [reset]mozilla::StyleFloatEdgemFloatEdge;// [reset]mozilla::StyleBoxDecorationBreakmBoxDecorationBreak;// [reset]protected:uint8_tmBorderStyle[4];// [reset] See nsStyleConsts.hpublic:// [reset] the colors to use for a simple border.// not used for -moz-border-colorsunion{struct{mozilla::StyleComplexColormBorderTopColor;mozilla::StyleComplexColormBorderRightColor;mozilla::StyleComplexColormBorderBottomColor;mozilla::StyleComplexColormBorderLeftColor;};mozilla::StyleComplexColormBorderColor[4];};staticmozilla::StyleComplexColornsStyleBorder::*BorderColorFieldFor(mozilla::SideaSide){switch(aSide){casemozilla::eSideTop:return&nsStyleBorder::mBorderTopColor;casemozilla::eSideRight:return&nsStyleBorder::mBorderRightColor;casemozilla::eSideBottom:return&nsStyleBorder::mBorderBottomColor;casemozilla::eSideLeft:return&nsStyleBorder::mBorderLeftColor;}MOZ_ASSERT_UNREACHABLE("Unknown side");returnnullptr;}protected:// mComputedBorder holds the CSS2.1 computed border-width values.// In particular, these widths take into account the border-style// for the relevant side, and the values are rounded to the nearest// device pixel (which is not part of the definition of computed// values). The presence or absence of a border-image does not// affect border-width values.nsMarginmComputedBorder;// mBorder holds the nscoord values for the border widths as they// would be if all the border-style values were visible (not hidden// or none). This member exists so that when we create structs// using the copy constructor during style resolution the new// structs will know what the specified values of the border were in// case they have more specific rules setting the border style.//// Note that this isn't quite the CSS specified value, since this// has had the enumerated border widths converted to lengths, and// all lengths converted to twips. But it's not quite the computed// value either. The values are rounded to the nearest device pixel.nsMarginmBorder;private:nscoordmTwipsPerPixel;nsStyleBorder&operator=(constnsStyleBorder&aOther)=delete;};#define ASSERT_BORDER_COLOR_FIELD(side_) \ static_assert(offsetof(nsStyleBorder, mBorder##side_##Color) == \ offsetof(nsStyleBorder, mBorderColor) + \ size_t(mozilla::eSide##side_) * \ sizeof(mozilla::StyleComplexColor), \ "mBorder" #side_ "Color must be at same offset " \ "as mBorderColor[mozilla::eSide" #side_ "]")ASSERT_BORDER_COLOR_FIELD(Top);ASSERT_BORDER_COLOR_FIELD(Right);ASSERT_BORDER_COLOR_FIELD(Bottom);ASSERT_BORDER_COLOR_FIELD(Left);#undef ASSERT_BORDER_COLOR_FIELDstructMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleOutline{explicitnsStyleOutline(constnsPresContext*aContext);nsStyleOutline(constnsStyleOutline&aOutline);~nsStyleOutline(){MOZ_COUNT_DTOR(nsStyleOutline);}voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleOutline*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleOutline,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleOutline();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleOutline,this);}voidRecalcData();nsChangeHintCalcDifference(constnsStyleOutline&aNewData)const;nsStyleCornersmOutlineRadius;// [reset] coord, percent, calc// This is the specified value of outline-width, but with length values// computed to absolute. mActualOutlineWidth stores the outline-width// value used by layout. (We must store mOutlineWidth for the same// style struct resolution reasons that we do nsStyleBorder::mBorder;// see that field's comment.)nscoordmOutlineWidth;// [reset] coord, enum (see nsStyleConsts.h)nscoordmOutlineOffset;// [reset]mozilla::StyleComplexColormOutlineColor;// [reset]uint8_tmOutlineStyle;// [reset] See nsStyleConsts.hnscoordGetOutlineWidth()const{returnmActualOutlineWidth;}boolShouldPaintOutline()const{returnmOutlineStyle==NS_STYLE_BORDER_STYLE_AUTO||(GetOutlineWidth()>0&&mOutlineStyle!=NS_STYLE_BORDER_STYLE_NONE);}protected:// The actual value of outline-width is the computed value (an absolute// length, forced to zero when outline-style is none) rounded to device// pixels. This is the value used by layout.nscoordmActualOutlineWidth;nscoordmTwipsPerPixel;};/** * An object that allows sharing of arrays that store 'quotes' property * values. This is particularly important for inheritance, where we want * to share the same 'quotes' value with a parent style context. */classnsStyleQuoteValues{public:typedefnsTArray<std::pair<nsString,nsString>>QuotePairArray;NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsStyleQuoteValues);QuotePairArraymQuotePairs;private:~nsStyleQuoteValues(){}};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleList{explicitnsStyleList(constnsPresContext*aContext);nsStyleList(constnsStyleList&aStyleList);~nsStyleList();voidFinishStyle(nsPresContext*aPresContext);conststaticboolkHasFinishStyle=true;void*operatornew(size_tsz,nsStyleList*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleList,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleList();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleList,this);}nsChangeHintCalcDifference(constnsStyleList&aNewData,constnsStyleDisplay*aOldDisplay)const;staticvoidShutdown(){sInitialQuotes=nullptr;sNoneQuotes=nullptr;}imgRequestProxy*GetListStyleImage()const{returnmListStyleImage?mListStyleImage->get():nullptr;}already_AddRefed<nsIURI>GetListStyleImageURI()const;constnsStyleQuoteValues::QuotePairArray&GetQuotePairs()const;voidSetQuotesInherit(constnsStyleList*aOther);voidSetQuotesInitial();voidSetQuotesNone();voidSetQuotes(nsStyleQuoteValues::QuotePairArray&&aValues);uint8_tmListStylePosition;// [inherited]RefPtr<nsStyleImageRequest>mListStyleImage;// [inherited]mozilla::CounterStylePtrmCounterStyle;// [inherited]private:RefPtr<nsStyleQuoteValues>mQuotes;// [inherited]nsStyleList&operator=(constnsStyleList&aOther)=delete;public:nsRectmImageRegion;// [inherited] the rect to use within an imageprivate:// nsStyleQuoteValues objects representing two common values, for sharing.staticmozilla::StaticRefPtr<nsStyleQuoteValues>sInitialQuotes;staticmozilla::StaticRefPtr<nsStyleQuoteValues>sNoneQuotes;};structnsStyleGridLine{// http://dev.w3.org/csswg/css-grid/#typedef-grid-line// XXXmats we could optimize memory size hereboolmHasSpan;int32_tmInteger;// 0 means not providednsStringmLineName;// Empty string means not provided.// These are the limits that we choose to clamp grid line numbers to.// http://dev.w3.org/csswg/css-grid/#overlarge-grids// mInteger is clamped to this range:staticconstint32_tkMinLine=-10000;staticconstint32_tkMaxLine=10000;nsStyleGridLine():mHasSpan(false),mInteger(0)// mLineName get its default constructor, the empty string{}nsStyleGridLine(constnsStyleGridLine&aOther){(*this)=aOther;}voidoperator=(constnsStyleGridLine&aOther){mHasSpan=aOther.mHasSpan;mInteger=aOther.mInteger;mLineName=aOther.mLineName;}booloperator!=(constnsStyleGridLine&aOther)const{returnmHasSpan!=aOther.mHasSpan||mInteger!=aOther.mInteger||mLineName!=aOther.mLineName;}voidSetToInteger(uint32_tvalue){mHasSpan=false;mInteger=value;mLineName.Truncate();}voidSetAuto(){mHasSpan=false;mInteger=0;mLineName.Truncate();}boolIsAuto()const{boolhaveInitialValues=mInteger==0&&mLineName.IsEmpty();MOZ_ASSERT(!(haveInitialValues&&mHasSpan),"should not have 'span' when other components are ""at their initial values");returnhaveInitialValues;}};// Computed value of the grid-template-columns or grid-template-rows property// (but *not* grid-template-areas.)// http://dev.w3.org/csswg/css-grid/#track-sizing//// This represents either:// * none:// mIsSubgrid is false, all three arrays are empty// * <track-list>:// mIsSubgrid is false,// mMinTrackSizingFunctions and mMaxTrackSizingFunctions// are of identical non-zero size,// and mLineNameLists is one element longer than that.// (Delimiting N columns requires N+1 lines:// one before each track, plus one at the very end.)//// An omitted <line-names> is still represented in mLineNameLists,// as an empty sub-array.//// A <track-size> specified as a single <track-breadth> is represented// as identical min and max sizing functions.// A 'fit-content(size)' <track-size> is represented as eStyleUnit_None// in the min sizing function and 'size' in the max sizing function.//// The units for nsStyleCoord are:// * eStyleUnit_Percent represents a <percentage>// * eStyleUnit_FlexFraction represents a <flex> flexible fraction// * eStyleUnit_Coord represents a <length>// * eStyleUnit_Enumerated represents min-content or max-content// * subgrid <line-name-list>?:// mIsSubgrid is true,// mLineNameLists may or may not be empty,// mMinTrackSizingFunctions and mMaxTrackSizingFunctions are empty.//// If mRepeatAutoIndex != -1 then that index is an <auto-repeat> and// mIsAutoFill == true means it's an 'auto-fill', otherwise 'auto-fit'.// mRepeatAutoLineNameListBefore is the list of line names before the track// size, mRepeatAutoLineNameListAfter the names after. (They are empty// when there is no <auto-repeat> track, i.e. when mRepeatAutoIndex == -1).// When mIsSubgrid is true, mRepeatAutoLineNameListBefore contains the line// names and mRepeatAutoLineNameListAfter is empty.structnsStyleGridTemplate{nsTArray<nsTArray<nsString>>mLineNameLists;nsTArray<nsStyleCoord>mMinTrackSizingFunctions;nsTArray<nsStyleCoord>mMaxTrackSizingFunctions;nsTArray<nsString>mRepeatAutoLineNameListBefore;nsTArray<nsString>mRepeatAutoLineNameListAfter;int16_tmRepeatAutoIndex;// -1 or the track index for an auto-fill/fit trackboolmIsAutoFill:1;boolmIsSubgrid:1;nsStyleGridTemplate():mRepeatAutoIndex(-1),mIsAutoFill(false),mIsSubgrid(false){}inlinebooloperator!=(constnsStyleGridTemplate&aOther)const{returnmIsSubgrid!=aOther.mIsSubgrid||mLineNameLists!=aOther.mLineNameLists||mMinTrackSizingFunctions!=aOther.mMinTrackSizingFunctions||mMaxTrackSizingFunctions!=aOther.mMaxTrackSizingFunctions||mIsAutoFill!=aOther.mIsAutoFill||mRepeatAutoIndex!=aOther.mRepeatAutoIndex||mRepeatAutoLineNameListBefore!=aOther.mRepeatAutoLineNameListBefore||mRepeatAutoLineNameListAfter!=aOther.mRepeatAutoLineNameListAfter;}boolHasRepeatAuto()const{returnmRepeatAutoIndex!=-1;}boolIsRepeatAutoIndex(uint32_taIndex)const{MOZ_ASSERT(aIndex<uint32_t(2*nsStyleGridLine::kMaxLine));returnint32_t(aIndex)==mRepeatAutoIndex;}};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStylePosition{explicitnsStylePosition(constnsPresContext*aContext);nsStylePosition(constnsStylePosition&aOther);~nsStylePosition();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStylePosition*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStylePosition,sz);}voidDestroy(nsPresContext*aContext){this->~nsStylePosition();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStylePosition,this);}nsChangeHintCalcDifference(constnsStylePosition&aNewData,constnsStyleVisibility*aOldStyleVisibility)const;/** * Return the used value for 'align-self' given our parent StyleContext * aParent (or null for the root). */uint8_tUsedAlignSelf(nsStyleContext*aParent)const;/** * Return the computed value for 'justify-items' given our parent StyleContext * aParent (or null for the root). */uint8_tComputedJustifyItems(nsStyleContext*aParent)const;/** * Return the used value for 'justify-self' given our parent StyleContext * aParent (or null for the root). */uint8_tUsedJustifySelf(nsStyleContext*aParent)const;mozilla::PositionmObjectPosition;// [reset]nsStyleSidesmOffset;// [reset] coord, percent, calc, autonsStyleCoordmWidth;// [reset] coord, percent, enum, calc, autonsStyleCoordmMinWidth;// [reset] coord, percent, enum, calcnsStyleCoordmMaxWidth;// [reset] coord, percent, enum, calc, nonensStyleCoordmHeight;// [reset] coord, percent, calc, autonsStyleCoordmMinHeight;// [reset] coord, percent, calcnsStyleCoordmMaxHeight;// [reset] coord, percent, calc, nonensStyleCoordmFlexBasis;// [reset] coord, percent, enum, calc, autonsStyleCoordmGridAutoColumnsMin;// [reset] coord, percent, enum, calc, flexnsStyleCoordmGridAutoColumnsMax;// [reset] coord, percent, enum, calc, flexnsStyleCoordmGridAutoRowsMin;// [reset] coord, percent, enum, calc, flexnsStyleCoordmGridAutoRowsMax;// [reset] coord, percent, enum, calc, flexuint8_tmGridAutoFlow;// [reset] enumerated. See nsStyleConsts.hmozilla::StyleBoxSizingmBoxSizing;// [reset] see nsStyleConsts.huint16_tmAlignContent;// [reset] fallback value in the high byteuint8_tmAlignItems;// [reset] see nsStyleConsts.huint8_tmAlignSelf;// [reset] see nsStyleConsts.huint16_tmJustifyContent;// [reset] fallback value in the high byteprivate:friendclassnsRuleNode;// mJustifyItems should only be read via ComputedJustifyItems(), which// lazily resolves its "auto" value. nsRuleNode needs direct access so// it can set mJustifyItems' value when populating this struct.uint8_tmJustifyItems;// [reset] see nsStyleConsts.hpublic:uint8_tmJustifySelf;// [reset] see nsStyleConsts.huint8_tmFlexDirection;// [reset] see nsStyleConsts.huint8_tmFlexWrap;// [reset] see nsStyleConsts.huint8_tmObjectFit;// [reset] see nsStyleConsts.hint32_tmOrder;// [reset] integerfloatmFlexGrow;// [reset] floatfloatmFlexShrink;// [reset] floatnsStyleCoordmZIndex;// [reset] integer, autonsStyleGridTemplatemGridTemplateColumns;nsStyleGridTemplatemGridTemplateRows;// nullptr for 'none'RefPtr<mozilla::css::GridTemplateAreasValue>mGridTemplateAreas;nsStyleGridLinemGridColumnStart;nsStyleGridLinemGridColumnEnd;nsStyleGridLinemGridRowStart;nsStyleGridLinemGridRowEnd;nsStyleCoordmGridColumnGap;// [reset] coord, percent, calcnsStyleCoordmGridRowGap;// [reset] coord, percent, calc// FIXME: Logical-coordinate equivalents to these WidthDepends... and// HeightDepends... methods have been introduced (see below); we probably// want to work towards removing the physical methods, and using the logical// ones in all cases.boolWidthDependsOnContainer()const{returnmWidth.GetUnit()==eStyleUnit_Auto||WidthCoordDependsOnContainer(mWidth);}// NOTE: For a flex item, "min-width:auto" is supposed to behave like// "min-content", which does depend on the container, so you might think we'd// need a special case for "flex item && min-width:auto" here. However,// we don't actually need that special-case code, because flex items are// explicitly supposed to *ignore* their min-width (i.e. behave like it's 0)// until the flex container explicitly considers it. So -- since the flex// container doesn't rely on this method, we don't need to worry about// special behavior for flex items' "min-width:auto" values here.boolMinWidthDependsOnContainer()const{returnWidthCoordDependsOnContainer(mMinWidth);}boolMaxWidthDependsOnContainer()const{returnWidthCoordDependsOnContainer(mMaxWidth);}// Note that these functions count 'auto' as depending on the// container since that's the case for absolutely positioned elements.// However, some callers do not care about this case and should check// for it, since it is the most common case.// FIXME: We should probably change the assumption to be the other way// around.// Consider this as part of moving to the logical-coordinate APIs.boolHeightDependsOnContainer()const{returnmHeight.GetUnit()==eStyleUnit_Auto||// CSS 2.1, 10.6.4, item (5)HeightCoordDependsOnContainer(mHeight);}// NOTE: The comment above MinWidthDependsOnContainer about flex items// applies here, too.boolMinHeightDependsOnContainer()const{returnHeightCoordDependsOnContainer(mMinHeight);}boolMaxHeightDependsOnContainer()const{returnHeightCoordDependsOnContainer(mMaxHeight);}boolOffsetHasPercent(mozilla::SideaSide)const{returnmOffset.Get(aSide).HasPercent();}// Logical-coordinate accessors for width and height properties,// given a WritingMode value. The definitions of these methods are// found in WritingModes.h (after the WritingMode class is fully// declared).inlinensStyleCoord&ISize(mozilla::WritingModeaWM);inlinensStyleCoord&MinISize(mozilla::WritingModeaWM);inlinensStyleCoord&MaxISize(mozilla::WritingModeaWM);inlinensStyleCoord&BSize(mozilla::WritingModeaWM);inlinensStyleCoord&MinBSize(mozilla::WritingModeaWM);inlinensStyleCoord&MaxBSize(mozilla::WritingModeaWM);inlineconstnsStyleCoord&ISize(mozilla::WritingModeaWM)const;inlineconstnsStyleCoord&MinISize(mozilla::WritingModeaWM)const;inlineconstnsStyleCoord&MaxISize(mozilla::WritingModeaWM)const;inlineconstnsStyleCoord&BSize(mozilla::WritingModeaWM)const;inlineconstnsStyleCoord&MinBSize(mozilla::WritingModeaWM)const;inlineconstnsStyleCoord&MaxBSize(mozilla::WritingModeaWM)const;inlineboolISizeDependsOnContainer(mozilla::WritingModeaWM)const;inlineboolMinISizeDependsOnContainer(mozilla::WritingModeaWM)const;inlineboolMaxISizeDependsOnContainer(mozilla::WritingModeaWM)const;inlineboolBSizeDependsOnContainer(mozilla::WritingModeaWM)const;inlineboolMinBSizeDependsOnContainer(mozilla::WritingModeaWM)const;inlineboolMaxBSizeDependsOnContainer(mozilla::WritingModeaWM)const;private:staticboolWidthCoordDependsOnContainer(constnsStyleCoord&aCoord);staticboolHeightCoordDependsOnContainer(constnsStyleCoord&aCoord){returnaCoord.HasPercent();}};structnsStyleTextOverflowSide{nsStyleTextOverflowSide():mType(NS_STYLE_TEXT_OVERFLOW_CLIP){}booloperator==(constnsStyleTextOverflowSide&aOther)const{returnmType==aOther.mType&&(mType!=NS_STYLE_TEXT_OVERFLOW_STRING||mString==aOther.mString);}booloperator!=(constnsStyleTextOverflowSide&aOther)const{return!(*this==aOther);}nsStringmString;uint8_tmType;};structnsStyleTextOverflow{nsStyleTextOverflow():mLogicalDirections(true){}booloperator==(constnsStyleTextOverflow&aOther)const{returnmLeft==aOther.mLeft&&mRight==aOther.mRight;}booloperator!=(constnsStyleTextOverflow&aOther)const{return!(*this==aOther);}// Returns the value to apply on the left side.constnsStyleTextOverflowSide&GetLeft(uint8_taDirection)const{NS_ASSERTION(aDirection==NS_STYLE_DIRECTION_LTR||aDirection==NS_STYLE_DIRECTION_RTL,"bad direction");return!mLogicalDirections||aDirection==NS_STYLE_DIRECTION_LTR?mLeft:mRight;}// Returns the value to apply on the right side.constnsStyleTextOverflowSide&GetRight(uint8_taDirection)const{NS_ASSERTION(aDirection==NS_STYLE_DIRECTION_LTR||aDirection==NS_STYLE_DIRECTION_RTL,"bad direction");return!mLogicalDirections||aDirection==NS_STYLE_DIRECTION_LTR?mRight:mLeft;}// Returns the first value that was specified.constnsStyleTextOverflowSide*GetFirstValue()const{returnmLogicalDirections?&mRight:&mLeft;}// Returns the second value, or null if there was only one value specified.constnsStyleTextOverflowSide*GetSecondValue()const{returnmLogicalDirections?nullptr:&mRight;}nsStyleTextOverflowSidemLeft;// start side when mLogicalDirections is truensStyleTextOverflowSidemRight;// end side when mLogicalDirections is trueboolmLogicalDirections;// true when only one value was specified};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleTextReset{explicitnsStyleTextReset(constnsPresContext*aContext);nsStyleTextReset(constnsStyleTextReset&aOther);~nsStyleTextReset();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleTextReset*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTextReset,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleTextReset();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleTextReset,this);}// Note the difference between this and// nsStyleContext::HasTextDecorationLines.boolHasTextDecorationLines()const{returnmTextDecorationLine!=NS_STYLE_TEXT_DECORATION_LINE_NONE&&mTextDecorationLine!=NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL;}nsChangeHintCalcDifference(constnsStyleTextReset&aNewData)const;nsStyleTextOverflowmTextOverflow;// [reset] enum, stringuint8_tmTextDecorationLine;// [reset] see nsStyleConsts.huint8_tmTextDecorationStyle;// [reset] see nsStyleConsts.huint8_tmUnicodeBidi;// [reset] see nsStyleConsts.hnscoordmInitialLetterSink;// [reset] 0 means normalfloatmInitialLetterSize;// [reset] 0.0f means normalmozilla::StyleComplexColormTextDecorationColor;// [reset]};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleText{explicitnsStyleText(constnsPresContext*aContext);nsStyleText(constnsStyleText&aOther);~nsStyleText();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleText*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleText,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleText();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleText,this);}nsChangeHintCalcDifference(constnsStyleText&aNewData)const;uint8_tmTextAlign;// [inherited] see nsStyleConsts.huint8_tmTextAlignLast;// [inherited] see nsStyleConsts.hboolmTextAlignTrue:1;// [inherited] see nsStyleConsts.hboolmTextAlignLastTrue:1;// [inherited] see nsStyleConsts.hmozilla::StyleTextJustifymTextJustify;// [inherited]uint8_tmTextTransform;// [inherited] see nsStyleConsts.hmozilla::StyleWhiteSpacemWhiteSpace;// [inherited] see nsStyleConsts.huint8_tmWordBreak;// [inherited] see nsStyleConsts.huint8_tmOverflowWrap;// [inherited] see nsStyleConsts.hmozilla::StyleHyphensmHyphens;// [inherited] see nsStyleConsts.huint8_tmRubyAlign;// [inherited] see nsStyleConsts.huint8_tmRubyPosition;// [inherited] see nsStyleConsts.huint8_tmTextSizeAdjust;// [inherited] see nsStyleConsts.huint8_tmTextCombineUpright;// [inherited] see nsStyleConsts.huint8_tmControlCharacterVisibility;// [inherited] see nsStyleConsts.huint8_tmTextEmphasisPosition;// [inherited] see nsStyleConsts.huint8_tmTextEmphasisStyle;// [inherited] see nsStyleConsts.huint8_tmTextRendering;// [inherited] see nsStyleConsts.hmozilla::StyleComplexColormTextEmphasisColor;// [inherited]mozilla::StyleComplexColormWebkitTextFillColor;// [inherited]mozilla::StyleComplexColormWebkitTextStrokeColor;// [inherited]nsStyleCoordmTabSize;// [inherited] coord, factor, calcnsStyleCoordmWordSpacing;// [inherited] coord, percent, calcnsStyleCoordmLetterSpacing;// [inherited] coord, normalnsStyleCoordmLineHeight;// [inherited] coord, factor, normalnsStyleCoordmTextIndent;// [inherited] coord, percent, calcnscoordmWebkitTextStrokeWidth;// [inherited] coordRefPtr<nsCSSShadowArray>mTextShadow;// [inherited] nullptr in case of a zero-lengthnsStringmTextEmphasisStyleString;// [inherited]boolWhiteSpaceIsSignificant()const{returnmWhiteSpace==mozilla::StyleWhiteSpace::Pre||mWhiteSpace==mozilla::StyleWhiteSpace::PreWrap||mWhiteSpace==mozilla::StyleWhiteSpace::PreSpace;}boolNewlineIsSignificantStyle()const{returnmWhiteSpace==mozilla::StyleWhiteSpace::Pre||mWhiteSpace==mozilla::StyleWhiteSpace::PreWrap||mWhiteSpace==mozilla::StyleWhiteSpace::PreLine;}boolWhiteSpaceOrNewlineIsSignificant()const{returnmWhiteSpace==mozilla::StyleWhiteSpace::Pre||mWhiteSpace==mozilla::StyleWhiteSpace::PreWrap||mWhiteSpace==mozilla::StyleWhiteSpace::PreLine||mWhiteSpace==mozilla::StyleWhiteSpace::PreSpace;}boolTabIsSignificant()const{returnmWhiteSpace==mozilla::StyleWhiteSpace::Pre||mWhiteSpace==mozilla::StyleWhiteSpace::PreWrap;}boolWhiteSpaceCanWrapStyle()const{returnmWhiteSpace==mozilla::StyleWhiteSpace::Normal||mWhiteSpace==mozilla::StyleWhiteSpace::PreWrap||mWhiteSpace==mozilla::StyleWhiteSpace::PreLine;}boolWordCanWrapStyle()const{returnWhiteSpaceCanWrapStyle()&&mOverflowWrap==NS_STYLE_OVERFLOWWRAP_BREAK_WORD;}boolHasTextEmphasis()const{return!mTextEmphasisStyleString.IsEmpty();}boolHasWebkitTextStroke()const{returnmWebkitTextStrokeWidth>0;}// These are defined in nsStyleStructInlines.h.inlineboolHasTextShadow()const;inlinensCSSShadowArray*GetTextShadow()const;// The aContextFrame argument on each of these is the frame this// style struct is for. If the frame is for SVG text or inside ruby,// the return value will be massaged to be something that makes sense// for those cases.inlineboolNewlineIsSignificant(constnsTextFrame*aContextFrame)const;inlineboolWhiteSpaceCanWrap(constnsIFrame*aContextFrame)const;inlineboolWordCanWrap(constnsIFrame*aContextFrame)const;mozilla::LogicalSideTextEmphasisSide(mozilla::WritingModeaWM)const;};structnsStyleImageOrientation{staticnsStyleImageOrientationCreateAsAngleAndFlip(doubleaRadians,boolaFlip){uint8_torientation(0);// Compute the final angle value, rounding to the closest quarter turn.doubleroundedAngle=fmod(aRadians,2*M_PI);if(roundedAngle<0.25*M_PI){orientation=ANGLE_0;}elseif(roundedAngle<0.75*M_PI){orientation=ANGLE_90;}elseif(roundedAngle<1.25*M_PI){orientation=ANGLE_180;}elseif(roundedAngle<1.75*M_PI){orientation=ANGLE_270;}else{orientation=ANGLE_0;}// Add a bit for 'flip' if needed.if(aFlip){orientation|=FLIP_MASK;}returnnsStyleImageOrientation(orientation);}staticnsStyleImageOrientationCreateAsFlip(){returnnsStyleImageOrientation(FLIP_MASK);}staticnsStyleImageOrientationCreateAsFromImage(){returnnsStyleImageOrientation(FROM_IMAGE_MASK);}// The default constructor yields 0 degrees of rotation and no flip.nsStyleImageOrientation():mOrientation(0){}boolIsDefault()const{returnmOrientation==0;}boolIsFlipped()const{returnmOrientation&FLIP_MASK;}boolIsFromImage()const{returnmOrientation&FROM_IMAGE_MASK;}boolSwapsWidthAndHeight()const{uint8_tangle=mOrientation&ORIENTATION_MASK;return(angle==ANGLE_90)||(angle==ANGLE_270);}mozilla::image::AngleAngle()const{switch(mOrientation&ORIENTATION_MASK){caseANGLE_0:returnmozilla::image::Angle::D0;caseANGLE_90:returnmozilla::image::Angle::D90;caseANGLE_180:returnmozilla::image::Angle::D180;caseANGLE_270:returnmozilla::image::Angle::D270;default:NS_NOTREACHED("Unexpected angle");returnmozilla::image::Angle::D0;}}nsStyleCoordAngleAsCoord()const{switch(mOrientation&ORIENTATION_MASK){caseANGLE_0:returnnsStyleCoord(0.0f,eStyleUnit_Degree);caseANGLE_90:returnnsStyleCoord(90.0f,eStyleUnit_Degree);caseANGLE_180:returnnsStyleCoord(180.0f,eStyleUnit_Degree);caseANGLE_270:returnnsStyleCoord(270.0f,eStyleUnit_Degree);default:NS_NOTREACHED("Unexpected angle");returnnsStyleCoord();}}booloperator==(constnsStyleImageOrientation&aOther)const{returnaOther.mOrientation==mOrientation;}booloperator!=(constnsStyleImageOrientation&aOther)const{return!(*this==aOther);}protected:enumBits{ORIENTATION_MASK=0x1|0x2,// The bottom two bits are the angle.FLIP_MASK=0x4,// Whether the image should be flipped.FROM_IMAGE_MASK=0x8,// Whether the image's inherent orientation};// should be used.enumAngles{ANGLE_0=0,ANGLE_90=1,ANGLE_180=2,ANGLE_270=3,};explicitnsStyleImageOrientation(uint8_taOrientation):mOrientation(aOrientation){}uint8_tmOrientation;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleVisibility{explicitnsStyleVisibility(constnsPresContext*aContext);nsStyleVisibility(constnsStyleVisibility&aVisibility);~nsStyleVisibility(){MOZ_COUNT_DTOR(nsStyleVisibility);}voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleVisibility*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleVisibility,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleVisibility();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleVisibility,this);}nsChangeHintCalcDifference(constnsStyleVisibility&aNewData)const;nsStyleImageOrientationmImageOrientation;// [inherited]uint8_tmDirection;// [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_*uint8_tmVisible;// [inherited]uint8_tmImageRendering;// [inherited] see nsStyleConsts.huint8_tmWritingMode;// [inherited] see nsStyleConsts.huint8_tmTextOrientation;// [inherited] see nsStyleConsts.huint8_tmColorAdjust;// [inherited] see nsStyleConsts.hboolIsVisible()const{return(mVisible==NS_STYLE_VISIBILITY_VISIBLE);}boolIsVisibleOrCollapsed()const{return((mVisible==NS_STYLE_VISIBILITY_VISIBLE)||(mVisible==NS_STYLE_VISIBILITY_COLLAPSE));}};structnsTimingFunction{enumclassType{Ease,// easeLinear,// linearEaseIn,// ease-inEaseOut,// ease-outEaseInOut,// ease-in-outStepStart,// step-start and steps(..., start)StepEnd,// step-end, steps(..., end) and steps(...)CubicBezier,// cubic-bezier()Frames,// frames()};// Whether the timing function type is represented by a spline,// and thus will have mFunc filled in.staticboolIsSplineType(TypeaType){returnaType!=Type::StepStart&&aType!=Type::StepEnd&&aType!=Type::Frames;}explicitnsTimingFunction(int32_taTimingFunctionType=NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE){AssignFromKeyword(aTimingFunctionType);}nsTimingFunction(floatx1,floaty1,floatx2,floaty2):mType(Type::CubicBezier){mFunc.mX1=x1;mFunc.mY1=y1;mFunc.mX2=x2;mFunc.mY2=y2;}enumclassKeyword{Implicit,Explicit};nsTimingFunction(TypeaType,uint32_taStepsOrFrames):mType(aType){MOZ_ASSERT(mType==Type::StepStart||mType==Type::StepEnd||mType==Type::Frames,"wrong type");mStepsOrFrames=aStepsOrFrames;}nsTimingFunction(constnsTimingFunction&aOther){*this=aOther;}TypemType;union{struct{floatmX1;floatmY1;floatmX2;floatmY2;}mFunc;struct{uint32_tmStepsOrFrames;};};nsTimingFunction&operator=(constnsTimingFunction&aOther){if(&aOther==this){return*this;}mType=aOther.mType;if(HasSpline()){mFunc.mX1=aOther.mFunc.mX1;mFunc.mY1=aOther.mFunc.mY1;mFunc.mX2=aOther.mFunc.mX2;mFunc.mY2=aOther.mFunc.mY2;}else{mStepsOrFrames=aOther.mStepsOrFrames;}return*this;}booloperator==(constnsTimingFunction&aOther)const{if(mType!=aOther.mType){returnfalse;}if(HasSpline()){returnmFunc.mX1==aOther.mFunc.mX1&&mFunc.mY1==aOther.mFunc.mY1&&mFunc.mX2==aOther.mFunc.mX2&&mFunc.mY2==aOther.mFunc.mY2;}returnmStepsOrFrames==aOther.mStepsOrFrames;}booloperator!=(constnsTimingFunction&aOther)const{return!(*this==aOther);}boolHasSpline()const{returnIsSplineType(mType);}private:voidAssignFromKeyword(int32_taTimingFunctionType);};namespacemozilla{structStyleTransition{StyleTransition(){/* leaves uninitialized; see also SetInitialValues */}explicitStyleTransition(constStyleTransition&aCopy);voidSetInitialValues();// Delay and Duration are in millisecondsconstnsTimingFunction&GetTimingFunction()const{returnmTimingFunction;}floatGetDelay()const{returnmDelay;}floatGetDuration()const{returnmDuration;}nsCSSPropertyIDGetProperty()const{returnmProperty;}nsIAtom*GetUnknownProperty()const{returnmUnknownProperty;}floatGetCombinedDuration()const{// http://dev.w3.org/csswg/css-transitions/#combined-durationreturnstd::max(mDuration,0.0f)+mDelay;}voidSetTimingFunction(constnsTimingFunction&aTimingFunction){mTimingFunction=aTimingFunction;}voidSetDelay(floataDelay){mDelay=aDelay;}voidSetDuration(floataDuration){mDuration=aDuration;}voidSetProperty(nsCSSPropertyIDaProperty){NS_ASSERTION(aProperty!=eCSSProperty_UNKNOWN&&aProperty!=eCSSPropertyExtra_variable,"invalid property");mProperty=aProperty;}voidSetUnknownProperty(nsCSSPropertyIDaProperty,constnsAString&aPropertyString);voidSetUnknownProperty(nsCSSPropertyIDaProperty,nsIAtom*aPropertyString);voidCopyPropertyFrom(constStyleTransition&aOther){mProperty=aOther.mProperty;mUnknownProperty=aOther.mUnknownProperty;}nsTimingFunction&TimingFunctionSlot(){returnmTimingFunction;}booloperator==(constStyleTransition&aOther)const;booloperator!=(constStyleTransition&aOther)const{return!(*this==aOther);}private:nsTimingFunctionmTimingFunction;floatmDuration;floatmDelay;nsCSSPropertyIDmProperty;nsCOMPtr<nsIAtom>mUnknownProperty;// used when mProperty is// eCSSProperty_UNKNOWN or// eCSSPropertyExtra_variable};structStyleAnimation{StyleAnimation(){/* leaves uninitialized; see also SetInitialValues */}explicitStyleAnimation(constStyleAnimation&aCopy);voidSetInitialValues();// Delay and Duration are in millisecondsconstnsTimingFunction&GetTimingFunction()const{returnmTimingFunction;}floatGetDelay()const{returnmDelay;}floatGetDuration()const{returnmDuration;}constnsString&GetName()const{returnmName;}dom::PlaybackDirectionGetDirection()const{returnmDirection;}dom::FillModeGetFillMode()const{returnmFillMode;}uint8_tGetPlayState()const{returnmPlayState;}floatGetIterationCount()const{returnmIterationCount;}voidSetTimingFunction(constnsTimingFunction&aTimingFunction){mTimingFunction=aTimingFunction;}voidSetDelay(floataDelay){mDelay=aDelay;}voidSetDuration(floataDuration){mDuration=aDuration;}voidSetName(constnsAString&aName){mName=aName;}voidSetDirection(dom::PlaybackDirectionaDirection){mDirection=aDirection;}voidSetFillMode(dom::FillModeaFillMode){mFillMode=aFillMode;}voidSetPlayState(uint8_taPlayState){mPlayState=aPlayState;}voidSetIterationCount(floataIterationCount){mIterationCount=aIterationCount;}nsTimingFunction&TimingFunctionSlot(){returnmTimingFunction;}booloperator==(constStyleAnimation&aOther)const;booloperator!=(constStyleAnimation&aOther)const{return!(*this==aOther);}private:nsTimingFunctionmTimingFunction;floatmDuration;floatmDelay;nsStringmName;// empty string for 'none'dom::PlaybackDirectionmDirection;dom::FillModemFillMode;uint8_tmPlayState;floatmIterationCount;// mozilla::PositiveInfinity<float>() means infinite};classStyleBasicShapefinal{public:explicitStyleBasicShape(StyleBasicShapeTypetype):mType(type),mFillRule(StyleFillRule::Nonzero){mPosition.SetInitialPercentValues(0.5f);}StyleBasicShapeTypeGetShapeType()const{returnmType;}nsCSSKeywordGetShapeTypeName()const;StyleFillRuleGetFillRule()const{returnmFillRule;}voidSetFillRule(StyleFillRuleaFillRule){MOZ_ASSERT(mType==StyleBasicShapeType::Polygon,"expected polygon");mFillRule=aFillRule;}Position&GetPosition(){MOZ_ASSERT(mType==StyleBasicShapeType::Circle||mType==StyleBasicShapeType::Ellipse,"expected circle or ellipse");returnmPosition;}constPosition&GetPosition()const{MOZ_ASSERT(mType==StyleBasicShapeType::Circle||mType==StyleBasicShapeType::Ellipse,"expected circle or ellipse");returnmPosition;}boolHasRadius()const{MOZ_ASSERT(mType==StyleBasicShapeType::Inset,"expected inset");nsStyleCoordzero;zero.SetCoordValue(0);NS_FOR_CSS_HALF_CORNERS(corner){if(mRadius.Get(corner)!=zero){returntrue;}}returnfalse;}nsStyleCorners&GetRadius(){MOZ_ASSERT(mType==StyleBasicShapeType::Inset,"expected inset");returnmRadius;}constnsStyleCorners&GetRadius()const{MOZ_ASSERT(mType==StyleBasicShapeType::Inset,"expected inset");returnmRadius;}// mCoordinates has coordinates for polygon or radii for// ellipse and circle.nsTArray<nsStyleCoord>&Coordinates(){returnmCoordinates;}constnsTArray<nsStyleCoord>&Coordinates()const{returnmCoordinates;}booloperator==(constStyleBasicShape&aOther)const{returnmType==aOther.mType&&mFillRule==aOther.mFillRule&&mCoordinates==aOther.mCoordinates&&mPosition==aOther.mPosition&&mRadius==aOther.mRadius;}booloperator!=(constStyleBasicShape&aOther)const{return!(*this==aOther);}NS_INLINE_DECL_THREADSAFE_REFCOUNTING(StyleBasicShape);private:~StyleBasicShape(){}StyleBasicShapeTypemType;StyleFillRulemFillRule;// mCoordinates has coordinates for polygon or radii for// ellipse and circle.// (top, right, bottom, left) for insetnsTArray<nsStyleCoord>mCoordinates;// position of center for ellipse or circlePositionmPosition;// corner radii for inset (0 if not set)nsStyleCornersmRadius;};structStyleShapeSource{StyleShapeSource():mURL(nullptr){}StyleShapeSource(constStyleShapeSource&aSource):StyleShapeSource(){if(aSource.mType==StyleShapeSourceType::URL){SetURL(aSource.mURL);}elseif(aSource.mType==StyleShapeSourceType::Shape){SetBasicShape(aSource.mBasicShape,aSource.mReferenceBox);}elseif(aSource.mType==StyleShapeSourceType::Box){SetReferenceBox(aSource.mReferenceBox);}}~StyleShapeSource(){ReleaseRef();}StyleShapeSource&operator=(constStyleShapeSource&aOther){if(this==&aOther){return*this;}if(aOther.mType==StyleShapeSourceType::URL){SetURL(aOther.mURL);}elseif(aOther.mType==StyleShapeSourceType::Shape){SetBasicShape(aOther.mBasicShape,aOther.mReferenceBox);}elseif(aOther.mType==StyleShapeSourceType::Box){SetReferenceBox(aOther.mReferenceBox);}else{ReleaseRef();mReferenceBox=StyleGeometryBox::NoBox;mType=StyleShapeSourceType::None;}return*this;}booloperator==(constStyleShapeSource&aOther)const{returnEqualsInternal<true>(aOther);}boolDefinitelyEquals(constStyleShapeSource&aOther)const{returnEqualsInternal<false>(aOther);}template<boolaPrecise>boolEqualsInternal(constStyleShapeSource&aOther)const{if(mType!=aOther.mType){returnfalse;}if(mType==StyleShapeSourceType::URL){returnaPrecise?mURL->Equals(*aOther.mURL):mURL->DefinitelyEqualURIs(*aOther.mURL);}elseif(mType==StyleShapeSourceType::Shape){return*mBasicShape==*aOther.mBasicShape&&mReferenceBox==aOther.mReferenceBox;}elseif(mType==StyleShapeSourceType::Box){returnmReferenceBox==aOther.mReferenceBox;}returntrue;}booloperator!=(constStyleShapeSource&aOther)const{return!(*this==aOther);}StyleShapeSourceTypeGetType()const{returnmType;}css::URLValue*GetURL()const{MOZ_ASSERT(mType==StyleShapeSourceType::URL,"Wrong shape source type!");returnmURL;}boolSetURL(css::URLValue*aValue){MOZ_ASSERT(aValue);ReleaseRef();mURL=aValue;mURL->AddRef();mType=StyleShapeSourceType::URL;returntrue;}StyleBasicShape*GetBasicShape()const{MOZ_ASSERT(mType==StyleShapeSourceType::Shape,"Wrong shape source type!");returnmBasicShape;}voidSetBasicShape(StyleBasicShape*aBasicShape,StyleGeometryBoxaReferenceBox){NS_ASSERTION(aBasicShape,"expected pointer");ReleaseRef();mBasicShape=aBasicShape;mBasicShape->AddRef();mReferenceBox=aReferenceBox;mType=StyleShapeSourceType::Shape;}StyleGeometryBoxGetReferenceBox()const{MOZ_ASSERT(mType==StyleShapeSourceType::Box||mType==StyleShapeSourceType::Shape,"Wrong shape source type!");returnmReferenceBox;}voidSetReferenceBox(StyleGeometryBoxaReferenceBox){ReleaseRef();mReferenceBox=aReferenceBox;mType=StyleShapeSourceType::Box;}private:voidReleaseRef(){if(mType==StyleShapeSourceType::Shape){NS_ASSERTION(mBasicShape,"expected pointer");mBasicShape->Release();}elseif(mType==StyleShapeSourceType::URL){NS_ASSERTION(mURL,"expected pointer");mURL->Release();}// Both mBasicShape and mURL are pointers in a union. Nulling one of them// nulls both of them.mURL=nullptr;}void*operatornew(size_t)=delete;union{StyleBasicShape*mBasicShape;css::URLValue*mURL;};StyleShapeSourceTypemType=StyleShapeSourceType::None;StyleGeometryBoxmReferenceBox=StyleGeometryBox::NoBox;};}// namespace mozilla// Consumers expect to be able to null-test mBinding to determine whether there// is a valid binding URI. Since we can't do URL resolution during parallel// style struct computation, we can't just null out the binding if the URL turns// out to be invalid. As such, we use this wrapper class to maintain this// behavior dynamically.classBindingHolder{public:BindingHolder(){}explicitBindingHolder(mozilla::css::URLValue*aPtr):mPtr(aPtr){}operatormozilla::css::URLValue*()const{returnGet();}mozilla::css::URLValue*operator->()const{returnGet();}mozilla::css::URLValue*Get()const{return(mPtr&&mPtr->GetURI())?mPtr.get():nullptr;}mozilla::css::URLValue*ForceGet()const{returnmPtr.get();}voidSet(mozilla::css::URLValue*aPtr){mPtr=aPtr;}private:RefPtr<mozilla::css::URLValue>mPtr;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleDisplay{typedefmozilla::StyleGeometryBoxStyleGeometryBox;explicitnsStyleDisplay(constnsPresContext*aContext);nsStyleDisplay(constnsStyleDisplay&aOther);~nsStyleDisplay();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleDisplay*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleDisplay,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleDisplay();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleDisplay,this);}nsChangeHintCalcDifference(constnsStyleDisplay&aNewData)const;// We guarantee that if mBinding is non-null, so are mBinding->GetURI() and// mBinding->mOriginPrincipal.BindingHoldermBinding;// [reset]mozilla::StyleDisplaymDisplay;// [reset] see nsStyleConsts.h StyleDisplaymozilla::StyleDisplaymOriginalDisplay;// [reset] saved mDisplay for// position:absolute/fixed// and float:left/right;// otherwise equal to// mDisplayuint8_tmContain;// [reset] see nsStyleConsts.h NS_STYLE_CONTAIN_*uint8_tmAppearance;// [reset]uint8_tmPosition;// [reset] see nsStyleConsts.h// [reset] See StyleFloat in nsStyleConsts.h.mozilla::StyleFloatmFloat;// [reset] Save mFloat for position:absolute/fixed; otherwise equal to mFloat.mozilla::StyleFloatmOriginalFloat;mozilla::StyleClearmBreakType;// [reset]uint8_tmBreakInside;// [reset] NS_STYLE_PAGE_BREAK_AUTO/AVOIDboolmBreakBefore;// [reset]boolmBreakAfter;// [reset]uint8_tmOverflowX;// [reset] see nsStyleConsts.huint8_tmOverflowY;// [reset] see nsStyleConsts.huint8_tmOverflowClipBox;// [reset] see nsStyleConsts.huint8_tmResize;// [reset] see nsStyleConsts.hmozilla::StyleOrientmOrient;// [reset] see nsStyleConsts.huint8_tmIsolation;// [reset] see nsStyleConsts.huint8_tmTopLayer;// [reset] see nsStyleConsts.huint8_tmWillChangeBitField;// [reset] see nsStyleConsts.h. Stores a// bitfield representation of the properties// that are frequently queried. This should// match mWillChange. Also tracks if any of the// properties in the will-change list require// a stacking context.nsCOMArray<nsIAtom>mWillChange;uint8_tmTouchAction;// [reset] see nsStyleConsts.huint8_tmScrollBehavior;// [reset] see nsStyleConsts.h NS_STYLE_SCROLL_BEHAVIOR_*uint8_tmScrollSnapTypeX;// [reset] see nsStyleConsts.h NS_STYLE_SCROLL_SNAP_TYPE_*uint8_tmScrollSnapTypeY;// [reset] see nsStyleConsts.h NS_STYLE_SCROLL_SNAP_TYPE_*nsStyleCoordmScrollSnapPointsX;// [reset]nsStyleCoordmScrollSnapPointsY;// [reset]mozilla::PositionmScrollSnapDestination;// [reset]nsTArray<mozilla::Position>mScrollSnapCoordinate;// [reset]// mSpecifiedTransform is the list of transform functions as// specified, or null to indicate there is no transform. (inherit or// initial are replaced by an actual list of transform functions, or// null, as appropriate.)uint8_tmBackfaceVisibility;uint8_tmTransformStyle;StyleGeometryBoxmTransformBox;// [reset] see nsStyleConsts.hRefPtr<nsCSSValueSharedList>mSpecifiedTransform;// [reset]nsStyleCoordmTransformOrigin[3];// [reset] percent, coord, calc, 3rd param is coord, calc onlynsStyleCoordmChildPerspective;// [reset] none, coordnsStyleCoordmPerspectiveOrigin[2];// [reset] percent, coord, calcnsStyleCoordmVerticalAlign;// [reset] coord, percent, calc, enum (see nsStyleConsts.h)nsStyleAutoArray<mozilla::StyleTransition>mTransitions;// [reset]// The number of elements in mTransitions that are not from repeating// a list due to another property being longer.uint32_tmTransitionTimingFunctionCount,mTransitionDurationCount,mTransitionDelayCount,mTransitionPropertyCount;nsStyleAutoArray<mozilla::StyleAnimation>mAnimations;// [reset]// The number of elements in mAnimations that are not from repeating// a list due to another property being longer.uint32_tmAnimationTimingFunctionCount,mAnimationDurationCount,mAnimationDelayCount,mAnimationNameCount,mAnimationDirectionCount,mAnimationFillModeCount,mAnimationPlayStateCount,mAnimationIterationCountCount;mozilla::StyleShapeSourcemShapeOutside;// [reset]boolIsBlockInsideStyle()const{returnmozilla::StyleDisplay::Block==mDisplay||mozilla::StyleDisplay::ListItem==mDisplay||mozilla::StyleDisplay::InlineBlock==mDisplay||mozilla::StyleDisplay::TableCaption==mDisplay||mozilla::StyleDisplay::FlowRoot==mDisplay;// Should TABLE_CELL be included here? They have// block frames nested inside of them.// (But please audit all callers before changing.)}boolIsBlockOutsideStyle()const{returnmozilla::StyleDisplay::Block==mDisplay||mozilla::StyleDisplay::Flex==mDisplay||mozilla::StyleDisplay::WebkitBox==mDisplay||mozilla::StyleDisplay::Grid==mDisplay||mozilla::StyleDisplay::ListItem==mDisplay||mozilla::StyleDisplay::Table==mDisplay||mozilla::StyleDisplay::FlowRoot==mDisplay;}staticboolIsDisplayTypeInlineOutside(mozilla::StyleDisplayaDisplay){returnmozilla::StyleDisplay::Inline==aDisplay||mozilla::StyleDisplay::InlineBlock==aDisplay||mozilla::StyleDisplay::InlineTable==aDisplay||mozilla::StyleDisplay::MozInlineBox==aDisplay||mozilla::StyleDisplay::InlineFlex==aDisplay||mozilla::StyleDisplay::WebkitInlineBox==aDisplay||mozilla::StyleDisplay::InlineGrid==aDisplay||mozilla::StyleDisplay::MozInlineGrid==aDisplay||mozilla::StyleDisplay::MozInlineStack==aDisplay||mozilla::StyleDisplay::Ruby==aDisplay||mozilla::StyleDisplay::RubyBase==aDisplay||mozilla::StyleDisplay::RubyBaseContainer==aDisplay||mozilla::StyleDisplay::RubyText==aDisplay||mozilla::StyleDisplay::RubyTextContainer==aDisplay||mozilla::StyleDisplay::Contents==aDisplay;}boolIsInlineOutsideStyle()const{returnIsDisplayTypeInlineOutside(mDisplay);}boolIsOriginalDisplayInlineOutsideStyle()const{returnIsDisplayTypeInlineOutside(mOriginalDisplay);}boolIsInnerTableStyle()const{returnmozilla::StyleDisplay::TableCaption==mDisplay||mozilla::StyleDisplay::TableCell==mDisplay||mozilla::StyleDisplay::TableRow==mDisplay||mozilla::StyleDisplay::TableRowGroup==mDisplay||mozilla::StyleDisplay::TableHeaderGroup==mDisplay||mozilla::StyleDisplay::TableFooterGroup==mDisplay||mozilla::StyleDisplay::TableColumn==mDisplay||mozilla::StyleDisplay::TableColumnGroup==mDisplay;}boolIsFloatingStyle()const{returnmozilla::StyleFloat::None!=mFloat;}boolIsAbsolutelyPositionedStyle()const{returnNS_STYLE_POSITION_ABSOLUTE==mPosition||NS_STYLE_POSITION_FIXED==mPosition;}boolIsRelativelyPositionedStyle()const{returnNS_STYLE_POSITION_RELATIVE==mPosition||NS_STYLE_POSITION_STICKY==mPosition;}boolIsPositionForcingStackingContext()const{returnNS_STYLE_POSITION_STICKY==mPosition||NS_STYLE_POSITION_FIXED==mPosition;}staticboolIsRubyDisplayType(mozilla::StyleDisplayaDisplay){returnmozilla::StyleDisplay::Ruby==aDisplay||mozilla::StyleDisplay::RubyBase==aDisplay||mozilla::StyleDisplay::RubyBaseContainer==aDisplay||mozilla::StyleDisplay::RubyText==aDisplay||mozilla::StyleDisplay::RubyTextContainer==aDisplay;}boolIsRubyDisplayType()const{returnIsRubyDisplayType(mDisplay);}boolIsOutOfFlowStyle()const{return(IsAbsolutelyPositionedStyle()||IsFloatingStyle());}boolIsScrollableOverflow()const{// mOverflowX and mOverflowY always match when one of them is// NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP.returnmOverflowX!=NS_STYLE_OVERFLOW_VISIBLE&&mOverflowX!=NS_STYLE_OVERFLOW_CLIP;}boolIsContainPaint()const{returnNS_STYLE_CONTAIN_PAINT&mContain;}/* Returns whether the element has the -moz-transform property * or a related property. */boolHasTransformStyle()const{returnmSpecifiedTransform!=nullptr||mTransformStyle==NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D||(mWillChangeBitField&NS_STYLE_WILL_CHANGE_TRANSFORM);}boolHasPerspectiveStyle()const{returnmChildPerspective.GetUnit()==eStyleUnit_Coord;}boolBackfaceIsHidden()const{returnmBackfaceVisibility==NS_STYLE_BACKFACE_VISIBILITY_HIDDEN;}// These are defined in nsStyleStructInlines.h.// The aContextFrame argument on each of these is the frame this// style struct is for. If the frame is for SVG text, the return// value will be massaged to be something that makes sense for// SVG text.inlineboolIsBlockInside(constnsIFrame*aContextFrame)const;inlineboolIsBlockOutside(constnsIFrame*aContextFrame)const;inlineboolIsInlineOutside(constnsIFrame*aContextFrame)const;inlineboolIsOriginalDisplayInlineOutside(constnsIFrame*aContextFrame)const;inlinemozilla::StyleDisplayGetDisplay(constnsIFrame*aContextFrame)const;inlineboolIsFloating(constnsIFrame*aContextFrame)const;inlineboolIsRelativelyPositioned(constnsIFrame*aContextFrame)const;inlineboolIsAbsolutelyPositioned(constnsIFrame*aContextFrame)const;// These methods are defined in nsStyleStructInlines.h./** * Returns whether the element is a containing block for its * absolutely positioned descendants. * aContextFrame is the frame for which this is the nsStyleDisplay. */inlineboolIsAbsPosContainingBlock(constnsIFrame*aContextFrame)const;/** * The same as IsAbsPosContainingBlock, except skipping the tests that * are based on the frame rather than the style context (thus * potentially returning a false positive). */template<classStyleContextLike>inlineboolIsAbsPosContainingBlockForAppropriateFrame(StyleContextLike*aStyleContext)const;/** * Returns true when the element has the transform property * or a related property, and supports CSS transforms. * aContextFrame is the frame for which this is the nsStyleDisplay. */inlineboolHasTransform(constnsIFrame*aContextFrame)const;/** * Returns true when the element is a containing block for its fixed-pos * descendants. * aContextFrame is the frame for which this is the nsStyleDisplay. */inlineboolIsFixedPosContainingBlock(constnsIFrame*aContextFrame)const;/** * The same as IsFixedPosContainingBlock, except skipping the tests that * are based on the frame rather than the style context (thus * potentially returning a false positive). */template<classStyleContextLike>inlineboolIsFixedPosContainingBlockForAppropriateFrame(StyleContextLike*aStyleContext)const;private:// Helpers for above functions, which do some but not all of the tests// for them (since transform must be tested separately for each).template<classStyleContextLike>inlineboolHasAbsPosContainingBlockStyleInternal(StyleContextLike*aStyleContext)const;template<classStyleContextLike>inlineboolHasFixedPosContainingBlockStyleInternal(StyleContextLike*aStyleContext)const;public:// Return the 'float' and 'clear' properties, with inline-{start,end} values// resolved to {left,right} according to the given writing mode. These are// defined in WritingModes.h.inlinemozilla::StyleFloatPhysicalFloats(mozilla::WritingModeaWM)const;inlinemozilla::StyleClearPhysicalBreakType(mozilla::WritingModeaWM)const;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleTable{explicitnsStyleTable(constnsPresContext*aContext);nsStyleTable(constnsStyleTable&aOther);~nsStyleTable();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleTable*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTable,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleTable();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleTable,this);}nsChangeHintCalcDifference(constnsStyleTable&aNewData)const;uint8_tmLayoutStrategy;// [reset] see nsStyleConsts.h NS_STYLE_TABLE_LAYOUT_*int32_tmSpan;// [reset] the number of columns spanned by a colgroup or col};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleTableBorder{explicitnsStyleTableBorder(constnsPresContext*aContext);nsStyleTableBorder(constnsStyleTableBorder&aOther);~nsStyleTableBorder();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleTableBorder*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleTableBorder,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleTableBorder();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleTableBorder,this);}nsChangeHintCalcDifference(constnsStyleTableBorder&aNewData)const;nscoordmBorderSpacingCol;// [inherited]nscoordmBorderSpacingRow;// [inherited]uint8_tmBorderCollapse;// [inherited]uint8_tmCaptionSide;// [inherited]uint8_tmEmptyCells;// [inherited]};enumnsStyleContentType{eStyleContentType_String=1,eStyleContentType_Image=10,eStyleContentType_Attr=20,eStyleContentType_Counter=30,eStyleContentType_Counters=31,eStyleContentType_OpenQuote=40,eStyleContentType_CloseQuote=41,eStyleContentType_NoOpenQuote=42,eStyleContentType_NoCloseQuote=43,eStyleContentType_AltContent=50,eStyleContentType_Uninitialized};classnsStyleContentData{public:nsStyleContentData():mType(eStyleContentType_Uninitialized){MOZ_COUNT_CTOR(nsStyleContentData);mContent.mString=nullptr;}nsStyleContentData(constnsStyleContentData&);~nsStyleContentData();nsStyleContentData&operator=(constnsStyleContentData&aOther);booloperator==(constnsStyleContentData&aOther)const;booloperator!=(constnsStyleContentData&aOther)const{return!(*this==aOther);}nsStyleContentTypeGetType()const{returnmType;}char16_t*GetString()const{MOZ_ASSERT(mType==eStyleContentType_String||mType==eStyleContentType_Attr);returnmContent.mString;}structCounterFunction{nsStringmIdent;// This is only used when it is a counters() function.nsStringmSeparator;mozilla::CounterStylePtrmCounterStyle;NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CounterFunction)booloperator==(constCounterFunction&aOther)const;booloperator!=(constCounterFunction&aOther)const{return!(*this==aOther);}private:~CounterFunction(){}};CounterFunction*GetCounters()const{MOZ_ASSERT(mType==eStyleContentType_Counter||mType==eStyleContentType_Counters);MOZ_ASSERT(mContent.mCounters->mCounterStyle.IsResolved(),"Counter style should have been resolved");returnmContent.mCounters;}nsStyleImageRequest*GetImageRequest()const{MOZ_ASSERT(mType==eStyleContentType_Image);returnmContent.mImage;}imgRequestProxy*GetImage()const{returnGetImageRequest()->get();}voidSetKeyword(nsStyleContentTypeaType){MOZ_ASSERT(aType==eStyleContentType_OpenQuote||aType==eStyleContentType_CloseQuote||aType==eStyleContentType_NoOpenQuote||aType==eStyleContentType_NoCloseQuote||aType==eStyleContentType_AltContent);MOZ_ASSERT(mType==eStyleContentType_Uninitialized,"should only initialize nsStyleContentData once");mType=aType;}voidSetString(nsStyleContentTypeaType,constchar16_t*aString){MOZ_ASSERT(aType==eStyleContentType_String||aType==eStyleContentType_Attr);MOZ_ASSERT(aString);MOZ_ASSERT(mType==eStyleContentType_Uninitialized,"should only initialize nsStyleContentData once");mType=aType;mContent.mString=NS_strdup(aString);}voidSetCounters(nsStyleContentTypeaType,already_AddRefed<CounterFunction>aCounterFunction){MOZ_ASSERT(aType==eStyleContentType_Counter||aType==eStyleContentType_Counters);MOZ_ASSERT(mType==eStyleContentType_Uninitialized,"should only initialize nsStyleContentData once");mType=aType;mContent.mCounters=aCounterFunction.take();MOZ_ASSERT(mContent.mCounters);}voidSetImageRequest(already_AddRefed<nsStyleImageRequest>aRequest){MOZ_ASSERT(mType==eStyleContentType_Uninitialized,"should only initialize nsStyleContentData once");mType=eStyleContentType_Image;mContent.mImage=aRequest.take();MOZ_ASSERT(mContent.mImage);}voidResolve(nsPresContext*aPresContext);private:nsStyleContentTypemType;union{char16_t*mString;nsStyleImageRequest*mImage;CounterFunction*mCounters;}mContent;};structnsStyleCounterData{nsStringmCounter;int32_tmValue;booloperator==(constnsStyleCounterData&aOther)const{returnmValue==aOther.mValue&&mCounter==aOther.mCounter;}booloperator!=(constnsStyleCounterData&aOther)const{return!(*this==aOther);}};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleContent{explicitnsStyleContent(constnsPresContext*aContext);nsStyleContent(constnsStyleContent&aContent);~nsStyleContent();voidFinishStyle(nsPresContext*aPresContext);conststaticboolkHasFinishStyle=true;void*operatornew(size_tsz,nsStyleContent*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleContent,sz);}voidDestroy(nsPresContext*aContext);nsChangeHintCalcDifference(constnsStyleContent&aNewData)const;uint32_tContentCount()const{returnmContents.Length();}// [reset]constnsStyleContentData&ContentAt(uint32_taIndex)const{returnmContents[aIndex];}nsStyleContentData&ContentAt(uint32_taIndex){returnmContents[aIndex];}voidAllocateContents(uint32_taCount){// We need to run the destructors of the elements of mContents, so we// delete and reallocate even if aCount == mContentCount. (If// nsStyleContentData had its members private and managed their// ownership on setting, we wouldn't need this, but that seems// unnecessary at this point.)mContents.Clear();mContents.SetLength(aCount);}uint32_tCounterIncrementCount()const{returnmIncrements.Length();}// [reset]constnsStyleCounterData&CounterIncrementAt(uint32_taIndex)const{returnmIncrements[aIndex];}voidAllocateCounterIncrements(uint32_taCount){mIncrements.Clear();mIncrements.SetLength(aCount);}voidSetCounterIncrementAt(uint32_taIndex,constnsString&aCounter,int32_taIncrement){mIncrements[aIndex].mCounter=aCounter;mIncrements[aIndex].mValue=aIncrement;}uint32_tCounterResetCount()const{returnmResets.Length();}// [reset]constnsStyleCounterData&CounterResetAt(uint32_taIndex)const{returnmResets[aIndex];}voidAllocateCounterResets(uint32_taCount){mResets.Clear();mResets.SetLength(aCount);}voidSetCounterResetAt(uint32_taIndex,constnsString&aCounter,int32_taValue){mResets[aIndex].mCounter=aCounter;mResets[aIndex].mValue=aValue;}protected:nsTArray<nsStyleContentData>mContents;nsTArray<nsStyleCounterData>mIncrements;nsTArray<nsStyleCounterData>mResets;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleUIReset{explicitnsStyleUIReset(constnsPresContext*aContext);nsStyleUIReset(constnsStyleUIReset&aOther);~nsStyleUIReset();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleUIReset*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleUIReset,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleUIReset();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleUIReset,this);}nsChangeHintCalcDifference(constnsStyleUIReset&aNewData)const;mozilla::StyleUserSelectmUserSelect;// [reset](selection-style)uint8_tmForceBrokenImageIcon;// [reset] (0 if not forcing, otherwise forcing)uint8_tmIMEMode;// [reset]mozilla::StyleWindowDraggingmWindowDragging;// [reset]uint8_tmWindowShadow;// [reset]floatmWindowOpacity;// [reset]RefPtr<nsCSSValueSharedList>mSpecifiedWindowTransform;// [reset]nsStyleCoordmWindowTransformOrigin[2];// [reset] percent, coord, calc};structnsCursorImage{boolmHaveHotspot;floatmHotspotX,mHotspotY;RefPtr<nsStyleImageRequest>mImage;nsCursorImage();nsCursorImage(constnsCursorImage&aOther);nsCursorImage&operator=(constnsCursorImage&aOther);booloperator==(constnsCursorImage&aOther)const;booloperator!=(constnsCursorImage&aOther)const{return!(*this==aOther);}imgRequestProxy*GetImage()const{returnmImage->get();}};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleUserInterface{explicitnsStyleUserInterface(constnsPresContext*aContext);nsStyleUserInterface(constnsStyleUserInterface&aOther);~nsStyleUserInterface();voidFinishStyle(nsPresContext*aPresContext);conststaticboolkHasFinishStyle=true;void*operatornew(size_tsz,nsStyleUserInterface*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleUserInterface,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleUserInterface();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleUserInterface,this);}nsChangeHintCalcDifference(constnsStyleUserInterface&aNewData)const;mozilla::StyleUserInputmUserInput;// [inherited]mozilla::StyleUserModifymUserModify;// [inherited] (modify-content)mozilla::StyleUserFocusmUserFocus;// [inherited] (auto-select)uint8_tmPointerEvents;// [inherited] see nsStyleConsts.huint8_tmCursor;// [inherited] See nsStyleConsts.hnsTArray<nsCursorImage>mCursorImages;// [inherited] images and coordsmozilla::StyleComplexColormCaretColor;// [inherited]inlineuint8_tGetEffectivePointerEvents(nsIFrame*aFrame)const;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleXUL{explicitnsStyleXUL(constnsPresContext*aContext);nsStyleXUL(constnsStyleXUL&aSource);~nsStyleXUL();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleXUL*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleXUL,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleXUL();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleXUL,this);}nsChangeHintCalcDifference(constnsStyleXUL&aNewData)const;floatmBoxFlex;// [reset] see nsStyleConsts.huint32_tmBoxOrdinal;// [reset] see nsStyleConsts.hmozilla::StyleBoxAlignmBoxAlign;// [reset]mozilla::StyleBoxDirectionmBoxDirection;// [reset]mozilla::StyleBoxOrientmBoxOrient;// [reset]mozilla::StyleBoxPackmBoxPack;// [reset]mozilla::StyleStackSizingmStackSizing;// [reset] see nsStyleConsts.h};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleColumn{explicitnsStyleColumn(constnsPresContext*aContext);nsStyleColumn(constnsStyleColumn&aSource);~nsStyleColumn();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleColumn*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleColumn,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleColumn();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleColumn,this);}nsChangeHintCalcDifference(constnsStyleColumn&aNewData)const;/** * This is the maximum number of columns we can process. It's used in both * nsColumnSetFrame and nsRuleNode. */staticconstuint32_tkMaxColumnCount=1000;uint32_tmColumnCount;// [reset] see nsStyleConsts.hnsStyleCoordmColumnWidth;// [reset] coord, autonsStyleCoordmColumnGap;// [reset] coord, normalmozilla::StyleComplexColormColumnRuleColor;// [reset]uint8_tmColumnRuleStyle;// [reset]uint8_tmColumnFill;// [reset] see nsStyleConsts.huint8_tmColumnSpan;// [reset] see nsStyleConsts.hvoidSetColumnRuleWidth(nscoordaWidth){mColumnRuleWidth=NS_ROUND_BORDER_TO_PIXELS(aWidth,mTwipsPerPixel);}nscoordGetComputedColumnRuleWidth()const{return(IsVisibleBorderStyle(mColumnRuleStyle)?mColumnRuleWidth:0);}protected:nscoordmColumnRuleWidth;// [reset] coordnscoordmTwipsPerPixel;};enumnsStyleSVGPaintType:uint8_t{eStyleSVGPaintType_None=1,eStyleSVGPaintType_Color,eStyleSVGPaintType_Server,eStyleSVGPaintType_ContextFill,eStyleSVGPaintType_ContextStroke};enumnsStyleSVGFallbackType:uint8_t{eStyleSVGFallbackType_NotSet,eStyleSVGFallbackType_None,eStyleSVGFallbackType_Color,};enumnsStyleSVGOpacitySource:uint8_t{eStyleSVGOpacitySource_Normal,eStyleSVGOpacitySource_ContextFillOpacity,eStyleSVGOpacitySource_ContextStrokeOpacity};classnsStyleSVGPaint{public:explicitnsStyleSVGPaint(nsStyleSVGPaintTypeaType=nsStyleSVGPaintType(0));nsStyleSVGPaint(constnsStyleSVGPaint&aSource);~nsStyleSVGPaint();nsStyleSVGPaint&operator=(constnsStyleSVGPaint&aOther);nsStyleSVGPaintTypeType()const{returnmType;}voidSetNone();voidSetColor(nscoloraColor);voidSetPaintServer(mozilla::css::URLValue*aPaintServer,nsStyleSVGFallbackTypeaFallbackType,nscoloraFallbackColor);voidSetPaintServer(mozilla::css::URLValue*aPaintServer){SetPaintServer(aPaintServer,eStyleSVGFallbackType_NotSet,NS_RGB(0,0,0));}voidSetContextValue(nsStyleSVGPaintTypeaType,nsStyleSVGFallbackTypeaFallbackType,nscoloraFallbackColor);voidSetContextValue(nsStyleSVGPaintTypeaType){SetContextValue(aType,eStyleSVGFallbackType_NotSet,NS_RGB(0,0,0));}nscolorGetColor()const{MOZ_ASSERT(mType==eStyleSVGPaintType_Color);returnmPaint.mColor;}mozilla::css::URLValue*GetPaintServer()const{MOZ_ASSERT(mType==eStyleSVGPaintType_Server);returnmPaint.mPaintServer;}nsStyleSVGFallbackTypeGetFallbackType()const{returnmFallbackType;}nscolorGetFallbackColor()const{MOZ_ASSERT(mType==eStyleSVGPaintType_Server||mType==eStyleSVGPaintType_ContextFill||mType==eStyleSVGPaintType_ContextStroke);returnmFallbackColor;}booloperator==(constnsStyleSVGPaint&aOther)const;booloperator!=(constnsStyleSVGPaint&aOther)const{return!(*this==aOther);}private:voidReset();voidAssign(constnsStyleSVGPaint&aOther);union{nscolormColor;mozilla::css::URLValue*mPaintServer;}mPaint;nsStyleSVGPaintTypemType;nsStyleSVGFallbackTypemFallbackType;nscolormFallbackColor;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleSVG{explicitnsStyleSVG(constnsPresContext*aContext);nsStyleSVG(constnsStyleSVG&aSource);~nsStyleSVG();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleSVG*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleSVG,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleSVG();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleSVG,this);}nsChangeHintCalcDifference(constnsStyleSVG&aNewData)const;nsStyleSVGPaintmFill;// [inherited]nsStyleSVGPaintmStroke;// [inherited]RefPtr<mozilla::css::URLValue>mMarkerEnd;// [inherited]RefPtr<mozilla::css::URLValue>mMarkerMid;// [inherited]RefPtr<mozilla::css::URLValue>mMarkerStart;// [inherited]nsTArray<nsStyleCoord>mStrokeDasharray;// [inherited] coord, percent, factornsTArray<nsCOMPtr<nsIAtom>>mContextProps;nsStyleCoordmStrokeDashoffset;// [inherited] coord, percent, factornsStyleCoordmStrokeWidth;// [inherited] coord, percent, factorfloatmFillOpacity;// [inherited]floatmStrokeMiterlimit;// [inherited]floatmStrokeOpacity;// [inherited]mozilla::StyleFillRulemClipRule;// [inherited]uint8_tmColorInterpolation;// [inherited] see nsStyleConsts.huint8_tmColorInterpolationFilters;// [inherited] see nsStyleConsts.hmozilla::StyleFillRulemFillRule;// [inherited] see nsStyleConsts.huint8_tmPaintOrder;// [inherited] see nsStyleConsts.huint8_tmShapeRendering;// [inherited] see nsStyleConsts.huint8_tmStrokeLinecap;// [inherited] see nsStyleConsts.huint8_tmStrokeLinejoin;// [inherited] see nsStyleConsts.huint8_tmTextAnchor;// [inherited] see nsStyleConsts.huint8_tmContextPropsBits;// [inherited] see nsStyleConsts.h.// Stores a bitfield representation of// the specified properties./// Returns true if style has been set to expose the computed values of/// certain properties (such as 'fill') to the contents of any linked images.boolExposesContextProperties()const{returnbool(mContextPropsBits);}nsStyleSVGOpacitySourceFillOpacitySource()const{uint8_tvalue=(mContextFlags&FILL_OPACITY_SOURCE_MASK)>>FILL_OPACITY_SOURCE_SHIFT;returnnsStyleSVGOpacitySource(value);}nsStyleSVGOpacitySourceStrokeOpacitySource()const{uint8_tvalue=(mContextFlags&STROKE_OPACITY_SOURCE_MASK)>>STROKE_OPACITY_SOURCE_SHIFT;returnnsStyleSVGOpacitySource(value);}boolStrokeDasharrayFromObject()const{returnmContextFlags&STROKE_DASHARRAY_CONTEXT;}boolStrokeDashoffsetFromObject()const{returnmContextFlags&STROKE_DASHOFFSET_CONTEXT;}boolStrokeWidthFromObject()const{returnmContextFlags&STROKE_WIDTH_CONTEXT;}voidSetFillOpacitySource(nsStyleSVGOpacitySourceaValue){mContextFlags=(mContextFlags&~FILL_OPACITY_SOURCE_MASK)|(aValue<<FILL_OPACITY_SOURCE_SHIFT);}voidSetStrokeOpacitySource(nsStyleSVGOpacitySourceaValue){mContextFlags=(mContextFlags&~STROKE_OPACITY_SOURCE_MASK)|(aValue<<STROKE_OPACITY_SOURCE_SHIFT);}voidSetStrokeDasharrayFromObject(boolaValue){mContextFlags=(mContextFlags&~STROKE_DASHARRAY_CONTEXT)|(aValue?STROKE_DASHARRAY_CONTEXT:0);}voidSetStrokeDashoffsetFromObject(boolaValue){mContextFlags=(mContextFlags&~STROKE_DASHOFFSET_CONTEXT)|(aValue?STROKE_DASHOFFSET_CONTEXT:0);}voidSetStrokeWidthFromObject(boolaValue){mContextFlags=(mContextFlags&~STROKE_WIDTH_CONTEXT)|(aValue?STROKE_WIDTH_CONTEXT:0);}boolHasMarker()const{returnmMarkerStart||mMarkerMid||mMarkerEnd;}/** * Returns true if the stroke is not "none" and the stroke-opacity is greater * than zero. This ignores stroke-widths as that depends on the context. */boolHasStroke()const{returnmStroke.Type()!=eStyleSVGPaintType_None&&mStrokeOpacity>0;}/** * Returns true if the fill is not "none" and the fill-opacity is greater * than zero. */boolHasFill()const{returnmFill.Type()!=eStyleSVGPaintType_None&&mFillOpacity>0;}private:// Flags to represent the use of context-fill and context-stroke// for fill-opacity or stroke-opacity, and context-value for stroke-dasharray,// stroke-dashoffset and stroke-width.enum{FILL_OPACITY_SOURCE_MASK=0x03,// fill-opacity: context-{fill,stroke}STROKE_OPACITY_SOURCE_MASK=0x0C,// stroke-opacity: context-{fill,stroke}STROKE_DASHARRAY_CONTEXT=0x10,// stroke-dasharray: context-valueSTROKE_DASHOFFSET_CONTEXT=0x20,// stroke-dashoffset: context-valueSTROKE_WIDTH_CONTEXT=0x40,// stroke-width: context-valueFILL_OPACITY_SOURCE_SHIFT=0,STROKE_OPACITY_SOURCE_SHIFT=2,};uint8_tmContextFlags;// [inherited]};structnsStyleFilter{nsStyleFilter();nsStyleFilter(constnsStyleFilter&aSource);~nsStyleFilter();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;nsStyleFilter&operator=(constnsStyleFilter&aOther);booloperator==(constnsStyleFilter&aOther)const;booloperator!=(constnsStyleFilter&aOther)const{return!(*this==aOther);}uint32_tGetType()const{returnmType;}constnsStyleCoord&GetFilterParameter()const{NS_ASSERTION(mType!=NS_STYLE_FILTER_DROP_SHADOW&&mType!=NS_STYLE_FILTER_URL&&mType!=NS_STYLE_FILTER_NONE,"wrong filter type");returnmFilterParameter;}voidSetFilterParameter(constnsStyleCoord&aFilterParameter,int32_taType);mozilla::css::URLValue*GetURL()const{MOZ_ASSERT(mType==NS_STYLE_FILTER_URL,"wrong filter type");returnmURL;}boolSetURL(mozilla::css::URLValue*aValue);nsCSSShadowArray*GetDropShadow()const{NS_ASSERTION(mType==NS_STYLE_FILTER_DROP_SHADOW,"wrong filter type");returnmDropShadow;}voidSetDropShadow(nsCSSShadowArray*aDropShadow);private:voidReleaseRef();uint32_tmType;// see NS_STYLE_FILTER_* constants in nsStyleConsts.hnsStyleCoordmFilterParameter;// coord, percent, factor, angleunion{mozilla::css::URLValue*mURL;nsCSSShadowArray*mDropShadow;};};template<>structnsTArray_CopyChooser<nsStyleFilter>{typedefnsTArray_CopyWithConstructors<nsStyleFilter>Type;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleSVGReset{explicitnsStyleSVGReset(constnsPresContext*aContext);nsStyleSVGReset(constnsStyleSVGReset&aSource);~nsStyleSVGReset();// Resolves and tracks the images in mMask. Only called with a Servo-backed// style system, where those images must be resolved later than the OMT// nsStyleSVGReset constructor call.voidFinishStyle(nsPresContext*aPresContext);conststaticboolkHasFinishStyle=true;void*operatornew(size_tsz,nsStyleSVGReset*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleSVGReset,sz);}voidDestroy(nsPresContext*aContext);nsChangeHintCalcDifference(constnsStyleSVGReset&aNewData)const;boolHasClipPath()const{returnmClipPath.GetType()!=mozilla::StyleShapeSourceType::None;}boolHasMask()const;boolHasNonScalingStroke()const{returnmVectorEffect==NS_STYLE_VECTOR_EFFECT_NON_SCALING_STROKE;}nsStyleImageLayersmMask;mozilla::StyleShapeSourcemClipPath;// [reset]nscolormStopColor;// [reset]nscolormFloodColor;// [reset]nscolormLightingColor;// [reset]floatmStopOpacity;// [reset]floatmFloodOpacity;// [reset]uint8_tmDominantBaseline;// [reset] see nsStyleConsts.huint8_tmVectorEffect;// [reset] see nsStyleConsts.huint8_tmMaskType;// [reset] see nsStyleConsts.h};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleVariables{nsStyleVariables();explicitnsStyleVariables(constnsPresContext*aContext);nsStyleVariables(constnsStyleVariables&aSource);~nsStyleVariables();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleVariables*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleVariables,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleVariables();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleVariables,this);}nsChangeHintCalcDifference(constnsStyleVariables&aNewData)const;mozilla::CSSVariableValuesmVariables;};structMOZ_NEEDS_MEMMOVABLE_MEMBERSnsStyleEffects{explicitnsStyleEffects(constnsPresContext*aContext);nsStyleEffects(constnsStyleEffects&aSource);~nsStyleEffects();voidFinishStyle(nsPresContext*aPresContext){}conststaticboolkHasFinishStyle=false;void*operatornew(size_tsz,nsStyleEffects*aSelf){returnaSelf;}void*operatornew(size_tsz,nsPresContext*aContext){returnaContext->PresShell()->AllocateByObjectID(mozilla::eArenaObjectID_nsStyleEffects,sz);}voidDestroy(nsPresContext*aContext){this->~nsStyleEffects();aContext->PresShell()->FreeByObjectID(mozilla::eArenaObjectID_nsStyleEffects,this);}nsChangeHintCalcDifference(constnsStyleEffects&aNewData)const;boolHasFilters()const{return!mFilters.IsEmpty();}nsTArray<nsStyleFilter>mFilters;// [reset]RefPtr<nsCSSShadowArray>mBoxShadow;// [reset] nullptr for 'none'nsRectmClip;// [reset] offsets from UL border edgefloatmOpacity;// [reset]uint8_tmClipFlags;// [reset] see nsStyleConsts.huint8_tmMixBlendMode;// [reset] see nsStyleConsts.h};#define STATIC_ASSERT_TYPE_LAYOUTS_MATCH(T1, T2) \ static_assert(sizeof(T1) == sizeof(T2), \ "Size mismatch between " #T1 " and " #T2); \ static_assert(alignof(T1) == alignof(T2), \ "Align mismatch between " #T1 " and " #T2); \#define STATIC_ASSERT_FIELD_OFFSET_MATCHES(T1, T2, field) \ static_assert(offsetof(T1, field) == offsetof(T2, field), \ "Field offset mismatch of " #field " between " #T1 " and " #T2); \/** * These *_Simple types are used to map Gecko types to layout-equivalent but * simpler Rust types, to aid Rust binding generation. * * If something in this types or the assertions below needs to change, ask * bholley, heycam or emilio before! * * <div rustbindgen="true" replaces="nsPoint"> */structnsPoint_Simple{nscoordx,y;};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsPoint,nsPoint_Simple);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsPoint,nsPoint_Simple,x);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsPoint,nsPoint_Simple,y);/** * <div rustbindgen="true" replaces="nsMargin"> */structnsMargin_Simple{nscoordtop,right,bottom,left;};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsMargin,nsMargin_Simple);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsMargin,nsMargin_Simple,top);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsMargin,nsMargin_Simple,right);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsMargin,nsMargin_Simple,bottom);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsMargin,nsMargin_Simple,left);/** * <div rustbindgen="true" replaces="nsRect"> */structnsRect_Simple{nscoordx,y,width,height;};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsRect,nsRect_Simple);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsRect,nsRect_Simple,x);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsRect,nsRect_Simple,y);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsRect,nsRect_Simple,width);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsRect,nsRect_Simple,height);/** * <div rustbindgen="true" replaces="nsSize"> */structnsSize_Simple{nscoordwidth,height;};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsSize,nsSize_Simple);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsSize,nsSize_Simple,width);STATIC_ASSERT_FIELD_OFFSET_MATCHES(nsSize,nsSize_Simple,height);/** * <div rustbindgen="true" replaces="mozilla::UniquePtr"> * * TODO(Emilio): This is a workaround and we should be able to get rid of this * one. */template<typenameT,typenameDeleter=mozilla::DefaultDelete<T>>structUniquePtr_Simple{T*mPtr;};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(mozilla::UniquePtr<int>,UniquePtr_Simple<int>);/** * <div rustbindgen replaces="nsTArray"></div> */template<typenameT>classnsTArray_Simple{T*mBuffer;public:// The existence of a destructor here prevents bindgen from deriving the Clone// trait via a simple memory copy.~nsTArray_Simple(){};};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray<nsStyleImageLayers::Layer>,nsTArray_Simple<nsStyleImageLayers::Layer>);STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray<mozilla::StyleTransition>,nsTArray_Simple<mozilla::StyleTransition>);STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsTArray<mozilla::StyleAnimation>,nsTArray_Simple<mozilla::StyleAnimation>);/** * <div rustbindgen replaces="nsCOMArray"></div> * * mozilla::ArrayIterator doesn't work well with bindgen. */template<typenameT>classnsCOMArray_Simple{nsTArray<nsISupports*>mBuffer;};STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsCOMArray<nsIContent>,nsCOMArray_Simple<nsIContent>);STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsCOMArray<nsINode>,nsCOMArray_Simple<nsINode>);STATIC_ASSERT_TYPE_LAYOUTS_MATCH(nsCOMArray<imgIContainer>,nsCOMArray_Simple<imgIContainer>);#endif /* nsStyleStruct_h___ */